(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>
原文地址:https://www.cnblogs.com/exmyth/p/14245134.html