maven配置 两种方法修改jdk版


为了修改maven建立项目默认以来的jdk版本,看了下maven配置
maven2.0默认使用jdk1.5致使检讨、@override 等annotation不可用。可用两种方法修改jdk版本
第一种:修改项目的pom.xml,影响单个项目,治标不治本java

XHTMLapache

 

1maven

2ide

3ui

4xml

5get

6io

7table

8jdk

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

相关文章
相关标签/搜索