maven项目编译与jdk版本的设置

转:https://blog.csdn.net/qq_27901123/article/details/80307561

使用maven项目使用jdk的版本依次查找的配置的顺序是:

1,setting文件

在setting文件的<proxies></proxies>节点添加<proxie></proxie>节点可设置maven的jdk编译版本的全局设置。

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


2,pom.xml文件 

有两种方式可以设置jdk编译版本。

方法一:使用maven插件

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


方法二:添加properties设置

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

3,其他默认配置

默认为1.5,暂没发现与maven版本的关联
 

猜你喜欢

转载自blog.csdn.net/HonsonNgai/article/details/89379923
今日推荐