[英]Maven install issue with Java 1.8 version
我寫了可以在Java 1.8(try塊)上編譯的代碼。 當我直接運行它時,它將為我編譯並運行。 當我嘗試在本地使用Maven進行構建時,遇到了一個問題,即要使用-source 7或更高版本。 我嘗試了所有可能的方式來使用Java 8,並且所有地方都只指定了8,但Maven似乎嘗試使用Java 1.6進行編譯。
可以請任何人幫助我,在哪里可以更正我的Maven以使用Java 1.8。
謝謝,Venkat
以下也應該工作:
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
</properties>
您可以使用maven-compiler-plugin
:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0<</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
只要記住要使用最新版本的插件即可。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.