不支持Maven Compile java错误菱形运算符

时间:2017-03-18 07:51:04

标签: java eclipse maven

我正在使用带有eclipse的maven,在编译项目时会出现以下错误

 [INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /D:/copay/CopayMobilePassBook/src/main/java/com/cherry/copay/mpassbook/process/impl/AccountsProcessImpl.java:[17,55] diamond operator is not supported in -source 1.5
  (use -source 7 or higher to enable diamond operator)
[ERROR] /D:/copay/CopayMobilePassBook/src/main/java/com/cherry/copay/mpassbook/process/support/ReversalProcessSupport.java:[89,88] diamond operator is not supported in -source 1.5
  (use -source 7 or higher to enable diamond operator)
[INFO] 2 errors 

但JDK的安装版本是8 项目 - >右键单击 - >属性 - >项目事实 - > java版本是1.8

我的maven配置有什么问题

1 个答案:

答案 0 :(得分:0)

可能是maven编译器插件配置问题

您可以查看Stack over flow answer: -

maven-compilation-error-use-source-7-or-higher-to-enable-diamond-operator

您可以使用正确版本的JDK版本

<properties>
    <maven-compiler-plugin>3.0</maven-compiler-plugin>
    <jdk-version>1.8</jdk-version>

</properties>

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>${maven-compiler-plugin}</version>
        <configuration>
            <compilerVersion>${jdk-version}</compilerVersion>
            <source>${jdk-version}</source>
            <target>${jdk-version}</target>
        </configuration>
</plugin>