maven - Java 17 Maven 编译器不允许出现 --release 错误

标签 maven java-17 google-code maven-compiler-plugin

我想在我的代码中使用 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>

参见:

https://github.com/spring-projects/spring-boot/issues/37993

关于maven - Java 17 Maven 编译器不允许出现 --release 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76556733/

相关文章:

svn - 如何使用 Tortoise SVN 从 google code 获取源代码?

version-control - 在 Google 代码中禁用源选项卡

android - 我如何告诉 gradle 使用最新的库、快照或不使用?

java - 安卓 : Could not GET/Find get repos from bintray. com

java - SonarQube 是否默认分析 Maven 依赖项?

使用 Microsoft OpenJDK 升级到 Java 17 后的 Java 编码问题

java - 复制maven项目的正确方法(备份)

Java-17 - 切换案例 - 应删除未使用的方法参数

java - 如何让 Maven 解析本地存储库的依赖关系

mercurial - 谷歌代码下载源码