我有一个使用 Java 8 的项目。
到目前为止,我们在 pom 中将源和目标版本指定为 1.8:
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
我们想利用 Java 9+ 的“-release”选项并添加了以下内容:
<maven.compiler.release>1.8</maven.compiler.release>
但是现在我们得到以下错误:
Fatal error compiling: release version 1.8 not supported
我们使用maven 3.5.3,maven-compiler-plugin 3.8.0版本和Java 10来编译项目。
这里有什么问题吗?
最佳答案
这应该可行
<maven.compiler.release>8</maven.compiler.release>
自 <release>
属性仅适用于发布的主要版本。
顺便说一下,这是假设这是实际编译器插件配置中使用的参数,有点像:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>${maven.compiler.release}</release>
</configuration>
</plugin>
关于java - 不支持发布版本 1.8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52419312/