Maven Plugins常用配置

官方文档:http://maven.apache.org/plugins/index.html#

这里主要介绍compiler插件的配置。http://maven.apache.org/plugins/maven-compiler-plugin/

默认的JDK编译版本是1.5,并不适合目前主流的1.6以上的开发环境,需要进行单独配置(示例为1.8)。

1,单独在某个项目的pom.xml中配置,仅适用该项目 官方文档

    <project>
      [...]
      <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>
      [...]
    </project>

2,在maven的setting.xml中进行配置 官方文档

    <profile>
      <id>jdk-1.8</id>

      <activation>
     <!--默认激活,激活条件JDK版本为1.8-->
<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 @ 2016-08-03 10:22  桐城东旭  阅读(3867)  评论(0编辑  收藏  举报