Maven 在pom文件中修改JDK版本

maven项目会用maven-compiler-plugin默认的jdk版本(一般是1.5)来进行j编译,如果不指明版本就容易出现版本不匹配的问题,可能导致编译不通过的问题。解决办法:在pom文件中配置maven-compiler-plugin插件(以jdk1.8)。

    <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.6.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

猜你喜欢

转载自blog.csdn.net/wangxuelei036/article/details/107358567