文章目錄
- 讓maven使用JDK1.8編譯
-
- 設定參數
- 配置插件
- 參考
讓maven使用JDK1.8編譯
讓maven使用你想要的JDK版本進行編譯,有兩個方式可以達到效果,這裡以目标版本JDK1.8舉例。
設定參數
<project>
[...]
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
[...]
</project>
配置插件
<project>
[...]
<build>
[...]
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
[...]
</build>
[...]
</project>
參考
《Setting the -source and -target of the Java Compiler》 - https://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html