我想在我的代码中使用 google-java-format 插件。因此,我在 Maven 编译器插件内向我的 pom 添加了一些导出配置,在运行全新安装过程后出现错误。我在外部尝试此命令idea 并通过命令行使用 maven 命令。
exporting a package from system module jdk.compiler is not allowed with --release
问候
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.version}</version>
<configuration>
<!--<release>${maven.compiler.target}</release>-->
<compilerArgs>
<arg> --add-opens=java.base/java.lang=ALL-UNNAMED</arg>
<arg>--add-opens=java.base/java.util=ALL-UNNAMED</arg>
<arg>--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED</arg>
<arg>--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED</arg>
<arg>--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED</arg>
<arg>--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED</arg>
<arg>--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED</arg>
<arg>--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED</arg>
<arg>--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED</arg>
</compilerArgs>
</configuration>
</plugin>
最佳答案
用途:
<maven.compiler.release></maven.compiler.release>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
参见:
关于maven - Java 17 Maven 编译器不允许出现 --release 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76556733/