您的位置:首页 > 编程语言 > Java开发

maven配置 两种方法修改jdk版

2016-07-13 00:00 459 查看
为了修改maven创建项目默认以来的jdk版本,看了下maven配置
maven2.0默认使用jdk1.5导致反省、@override 等annotation不可用。可用两种方法修改jdk版本
第一种:修改项目的pom.xml,影响单个项目,治标不治本

XHTML

1
2
3
4
5
6
7
8
9
10
11
12
13
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
pom中增加build配置,指定java版本为1.6
第二种:修改maven配置,影响maven建立的所有项目
到maven安装目录的conf文件夹下,修改settings.xml文件,如下:

Java

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<profiles>
<profile>
<id>jdk-1.6</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.6</jdk>
</activation>
<properties>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<maven.compiler.compilerVersion>1.6</maven.compiler.compilerVersion>
</properties>
</profile>
</profiles>
这样便能对所有默认的maven项目指定jdk为1.6
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: