admin管理员组文章数量:1299997
I have the following simple POM, with only one .java
file in src/main/java
:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns=".0.0"
xmlns:xsi=";
xsi:schemaLocation=".0.0 .0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>test</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<mavenpiler.release>21</mavenpiler.release>
</properties>
</project>
When I run mvn compile
I get the following error:
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] Source option 5 is no longer supported. Use 8 or later.
[ERROR] Target option 5 is no longer supported. Use 8 or later.
Compilation works if I provide mavenpiler.source
and mavenpiler.target
.
My understanding is that mavenpiler.release
is supposed to pass the --release
to the javac
. However, the --release
supersedes, and is not compatible with, --source
and --target
according to official javac documentations.
Which part did I get wrong?
The output of mvn -v
is the following:
Apache Maven 3.8.7
Maven home: /usr/share/maven
Java version: 21.0.6, vendor: Ubuntu, runtime: /usr/lib/jvm/java-21-openjdk-amd64
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "5.15.167.4-microsoft-standard-wsl2", arch: "amd64", family: "unix"
Answering Comments
Since one comment mentioned it, this question is not the same as this one.
- I know the solution to my problem, what I need is an explanation.
- My question has nothing to do with Eclipse or any IDE.
- My question is about
mavenpiler.release
and how does it apply to compilation flags.
I originally wanted my question to be brief, so I didn't state every thing I tried. Providing maven-compiler-plugin
latest version (3.13.0) didn't work. The error message however is different:
Fatal error compiling: error: release version 9 not supported -> [Help 1]
I tried with an old (9) and a new (21) versions of Java. I get the same result when I provide configuration/release.
<build>
<plugins>
<plugin>
<groupId>.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<release>9</release>
</configuration>
</plugin>
</plugins>
</build>
本文标签: javaSimple Maven project with mavencompilerrelease not workingStack Overflow
版权声明:本文标题:java - Simple Maven project with maven.compiler.release not working - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741652204a2390546.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论