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

问题描述 投票:0回答:2

我想在我的代码中使用 google-java-format 插件。因此,我在 Maven 编译器插件内的 pom 中添加了一些导出配置,在运行全新安装过程后出现错误。我在想法之外尝试此命令,并且通过命令行使用 Maven 命令。

不允许从系统模块 jdk.compiler 导出包 与--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 java-17 google-code maven-compiler-plugin
2个回答
0
投票

我在 Spring Boot 3.1.x 和 java 17 中遇到了同样的问题。 编译器参数“--add-exports”不再适用于 Spring Boot 3.1.x。

Spring boot 到版本 3.0.9 可以使用该编译器参数正常工作,但 3.1.x 版本都失败(3.1.0、3.1.1、3.1.2)。


0
投票

用途:

<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

© www.soinside.com 2019 - 2024. All rights reserved.