diamond运算符,指的是JDK1.7的一个新特性。Maven默认用的是JDK1.6去编译。所以需要配置成更高的版本,有以下几种解决办法:

1.在项目pom.xml中加入下面的配置即可

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

2.直接在pom.xml中配置Maven的编译插件

<build>
    <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>
    </plugins>
</build>

3.在配置的maven安装包的setting.xml中的profiles标签中加入以下标签

<profile>
    <id>jdk-1.8</id>
    <activation>
        <activeByDefault>true</activeByDefault>
        <jdk>1.8</jdk>
    </activation>
    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
    </properties>
</profile>

 

相关文章:

  • 2021-09-08
  • 2021-12-24
  • 2021-11-15
  • 2021-09-24
  • 2021-07-21
  • 2021-04-14
  • 2021-08-03
猜你喜欢
  • 2021-06-28
  • 2022-12-23
  • 2021-11-19
  • 2021-08-01
  • 2021-11-06
相关资源
相似解决方案