/**PageBeginHtml Block Begin **/ /***自定义返回顶部小火箭***/ /*生成博客目录的JS 开始*/ /*生成博客目录的JS 结束*/

解决:Java source1.6不支持diamond运算符,请使用source 7或更高版本以启用diamond运算符

解决:Java source1.6不支持diamond运算符,请使用source 7或更高版本以启用diamond运算符

 

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>
复制代码

 

posted @ 2021-07-29 12:59  一品堂.技术学习笔记  阅读(640)  评论(0编辑  收藏  举报