我的机器上有jdk 7和8,JAVA_HOME指向Java 7,Jenkins使用Java8。我创建了一个maven项目,我试图使用Java 8在jenkins上构建它,但出现以下错误: / p>
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project maven-demo: Compilation failure -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
Build step 'Invoke top-level Maven targets' marked build as failure
Finished: FAILURE
在pom.xml中,我添加了以下内容:
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
</properties>
和
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<verbose>true</verbose>
<fork>true</fork>
<source>1.8</source>
<target>1.8</target>
<executable>path/to/jdk/bin/javac</executable>
</configuration>
</plugin>
</plugins>
</build>
但是使用上述2种方法中的任何一种,我仍然会遇到相同的错误。
如何更新它以使Maven使用Java 8?
答案 0 :(得分:1)
您必须在全局工具配置下使用不同jdks的名称和JAVA_HOME配置您的Jenkins。 http://path-to-your-jenkins:8080/configureTools/。 之后,您可以在项目配置http://path-to-your-jenkins:8080/job/yourJob/configure中选择JDK。在“ JDK”字段的“常规”选项卡中。