【问题标题】:COMPILATION ERROR : Failed to execute maven-compiler-plugin:2.3.2:compile编译错误:无法执行 maven-compiler-plugin:2.3.2:compile
【发布时间】:2020-08-13 14:25:59
【问题描述】:

我尝试使用 maven 在 jenkins 简单项目上构建,但我收到此错误,我不明白是什么问题

enter code here
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] error: Source option 6 is no longer supported. Use 7 or later.
[ERROR] error: Target option 6 is no longer supported. Use 7 or later.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default- 
compile) on project server: Compilation failure: Compilation failure: 

【问题讨论】:

  • 您能否接受以下答案之一或解释为什么这些答案对您不起作用?

标签: java maven jenkins


【解决方案1】:

由于错误明确指出maven-compiler-plugin 应配置 java 7 或更高版本。

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.2</version>
    <configuration>
        <source>1.7</source>
        <target>1.7</target>
    </configuration>
</plugin>

同时更新 maven-compiler-plugin,因为 2.3.2 真的太旧了。检查这个以获得进一步的解释Maven Compilation Error: (use -source 7 or higher to enable diamond operator)

【讨论】:

  • 我不明白我需要改变的地方,你能详细解释一下吗
【解决方案2】:

你可以通过 3 种方式解决它

  1. 升级到 JDK7 或 JDK8 (meh)
  2. 使用 maven-compiler-plugin 版本或更高版本,因为
  3. 指示 maven-compiler-plugin 使用源级别 7 和目标 7
<plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
            <source>1.7</source>
            <target>1.7</target>
        </configuration>
    </plugin> 

<properties>
    <maven.compiler.source>1.7</maven.compiler.source>
    <maven.compiler.target>1.7</maven.compiler.target>
  </properties>

【讨论】:

    猜你喜欢
    • 2018-11-13
    • 2017-07-20
    • 2015-05-07
    • 2022-08-10
    • 2020-07-29
    • 1970-01-01
    • 2019-02-20
    • 1970-01-01
    • 2013-12-11
    相关资源
    最近更新 更多