【问题标题】:how to make maven with jenkins use specific jdk?如何让詹金斯的 Maven 使用特定的 jdk?
【发布时间】:2019-02-27 13:22:04
【问题描述】:

我的机器上有 jdk 7 和 8,JAVA_HOME 指向 java 7,Jenkins 使用 java 8。我创建了一个 maven 项目,我正在尝试使用 java 8 在 jenkins 上构建它,但出现以下错误:

[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?

【问题讨论】:

  • 你真的更新了&lt;executable&gt; 指向你的jdk8吗?
  • 是的,我做了,但没有用

标签: java maven jenkins


【解决方案1】:

您必须在全局工具配置下使用不同 jdks 的名称和 JAVA_HOME 配置您的 Jenkins。 http://path-to-your-jenkins:8080/configureTools/。 之后您可以在项目配置http://path-to-your-jenkins:8080/job/yourJob/configure 中选择JDK。在 JDK 字段的“常规”选项卡中。

【讨论】:

  • 哇,指向 General 部分的指针正是我所需要的
  • 谢谢,我也遇到了这个问题,对我有帮助。我打个招呼:在 Global Tool Configuration 中至少添加两个不同的 java 版本,然后 General 选项卡将显示 jdk 选择项
猜你喜欢
  • 2019-07-19
  • 1970-01-01
  • 2022-01-08
  • 2013-04-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多