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>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM