构建Maven项目中的编译错误 [英] Compilation error in building maven project

查看:86
本文介绍了构建Maven项目中的编译错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在尝试从Jenkins构建Maven工件并将其部署到Nexus Repository Manager中,但是在构建过程中我们面临编译错误. 这是我们得到的错误.

we are trying to build and deploy a maven artifact into our Nexus Repository Manager from Jenkins, But we are facing compilation error during the build. This is the error that we are getting.!

ERROR]无法执行目标 org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile (默认编译)在project studentapp上:编译失败ERROR]否 在此环境中提供了编译器.也许您正在跑步 JRE而不是JDK? [ERROR]编译错误:[INFO] -------------------------------------------------- ----------- [错误]在此环境中未提供编译器.也许你在跑步 在JRE而不是JDK上?

ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile (default-compile) on project studentapp: Compilation failure ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK? [ERROR] COMPILATION ERROR : [INFO] ------------------------------------------------------------- [ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

这是我们的 pom.xml 文件.

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.jdevs</groupId>
  <artifactId>studentapp</artifactId>
  <version>2.5-SNAPSHOT</version>
  <packaging>war</packaging>

  <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
  </properties>

  <build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.5.1</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.6</version>
        <configuration>
          <warSourceDirectory>WebContent</warSourceDirectory>
          <failOnMissingWebXml>false</failOnMissingWebXml>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
      </plugin>
    </plugins>
  </build>
   <distributionManagement>
        <repository>
            <id>deployment</id>
            <name>Internal Releases</name>
            <url>http://rig.eastus.cloudapp.azure.com:8081/repository/maven-releases/</url>
        </repository>
        <snapshotRepository>
            <id>deployment</id>
            <name>Internal Snapshot Releases</name>
            <url>http://rig.eastus.cloudapp.azure.com:8081/repository/maven-snapshots/</url>
        </snapshotRepository> 
    </distributionManagement>
  <dependencies>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.1.0</version>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>3.5.1</version>
      <type>maven-plugin</type>
    </dependency>

    <dependency>
      <groupId>commons-httpclient</groupId>
      <artifactId>commons-httpclient</artifactId>
      <version>3.1</version>
    </dependency>

    <dependency>
      <groupId>org.apache.jackrabbit</groupId>
      <artifactId>jackrabbit-webdav</artifactId>
      <version>1.5.0</version>
    </dependency>

    <dependency>
      <groupId>org.sonatype.sisu</groupId>
      <artifactId>sisu-guice</artifactId>
      <version>2.1.7</version>
      <type>pom</type>
    </dependency>

    <dependency>
      <groupId>javax.inject</groupId>
      <artifactId>javax.inject</artifactId>
      <version>1</version>
    </dependency>

    <dependency>
      <groupId>aopalliance</groupId>
      <artifactId>aopalliance</artifactId>
      <version>1.0</version>
    </dependency>

    <dependency>
      <groupId>org.apache.maven</groupId>
      <artifactId>maven-plugin-api</artifactId>
      <version>3.5.0</version>
    </dependency>

    <dependency>
      <groupId>org.apache.maven</groupId>
      <artifactId>maven-artifact</artifactId>
      <version>3.5.0</version>
    </dependency>

    <dependency>
      <groupId>org.apache.maven.plugin-tools</groupId>
      <artifactId>maven-plugin-annotations</artifactId>
      <version>3.5.1</version>
      <scope>provided</scope>
    </dependency>


  </dependencies>
</project>

推荐答案

重新配置您的 Jenkins .从主页转到管理插件",然后转到全局工具配置".用正确的JDK文件夹路径重新初始化JAVA_HOME字段.

Reconfigure your Jenkins . From home page goto Manage Plugins and then goto Global Tool Configuration. Reintialize JAVA_HOME field with the correct path to JDK folder.

这篇关于构建Maven项目中的编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆