【发布时间】:2020-03-21 19:35:06
【问题描述】:
我有两个关于maven.compiler.release-tag 的问题
我要换
<properties>
<maven.compiler.source>12</maven.compiler.source>
<maven.compiler.target>12</maven.compiler.target>
</properties>
到
<properties>
<maven.compiler.release>12</maven.compiler.release>
</properties>
如果我使用<maven.compiler.release>-property,是否还要在插件中设置发布标签?
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<!-- do I need that ? -->
<release>12</release>
</configuration>
</plugin>
根据https://www.baeldung.com/maven-java-version,设置为两者。
如果我使用maven.compiler.release 而不是maven.compiler.source 和maven.compiler.target,那么-bootclasspath 也会被设置并进行交叉编译。 这是什么意思?设置-bootclasspath的编译文件大小会更大还是编译需要更多时间?
【问题讨论】:
-
只需
<maven.compiler.release>12</maven.compiler.release>属性就足够了。而且您不需要设置 maven-compiler-plugin 的配置。发布标签的配置是自动拾取的。 bootclasspath 部分是通过使用--release选项自动完成的。文件的大小与此无关......所以简单的建议使用release部分用于JDK9 +,否则源/目标...... -
@khmarbaise 方式不对您的评论做出答复?我们可以投一些赞成票,并将这个问题标记为已解决。
-
请注意,您的示例中正确的发布版本是“12”,而不是“1.12”。
标签: maven maven-compiler-plugin