(default-compile) on project app: Fatal error compiling: 無效的標記: --release -> [Help 1]


 

<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<release>8</release>
</configuration>
</plugin>
</plugins>

如果你的pom.xml文件如上所示,並且使用jdk8,則會報錯

(default-compile) on project app: Fatal error compiling: 無效的標記: --release -> [Help 1]

 

查閱官方文檔,release Java9才支持

 

http://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#release

<release>

The -release argument for the Java compiler, supported since Java9
  • Typejava.lang.String
  • Since3.6
  • RequiredNo
  • User Propertymaven.compiler.release

 

 

解決辦法,可以設計jdk版本到Java9+,或者更改maven-compiler-plugin配置

參考如下

<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<compilerArguments>
<bootclasspath>${java.home}/lib/rt.jar</bootclasspath>
</compilerArguments>
<encoding>${project.build.sourceEncoding}</encoding>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
</annotationProcessorPaths>
</configuration>

如果沒有使用 projectlombok,只用這個配置

<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<compilerArguments>
<bootclasspath>${java.home}/lib/rt.jar</bootclasspath>
</compilerArguments>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>

 


免責聲明!

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



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