[英]Java maven project, build failing to version mismatch
I have cloned a git repo and am trying to build it locally, but getting the following error我已经克隆了一个 git repo 并试图在本地构建它,但收到以下错误
[INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.850 s [INFO] Finished at: 2021-07-12T15:42:57+02:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project gtvg: Fatal error compiling: invalid flag: --release -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[信息] 构建失败 [信息] ------------------------------------------ ------------------------------ [INFO] 总时间:0.850 s [INFO] 完成时间:2021-07-12T15: 42:57+02:00 [信息]---------------------------------------- -------------------------------- [错误] 无法执行目标 org.apache.maven.plugins:maven-compiler -plugin:3.8.1:compile (default-compile) on project gtvg: Fatal error compiling: invalid flag: --release -> [Help 1] [ERROR] [ERROR] 要查看错误的完整堆栈跟踪,请重新- 使用 -e 开关运行 Maven。 [ERROR] Re-run Maven using the -X switch to enable full debug logging.
[错误] 使用 -X 开关重新运行 Maven 以启用完整的调试日志记录。 [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[ERROR] [ERROR] 有关错误和可能的解决方案的更多信息,请阅读以下文章: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
I have java jdk 8 and 11 installed, currently using java 8我安装了 java jdk 8 和 11,目前使用的是 java 8
java -version
16:03:24
openjdk version "1.8.0_242"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_242-b08)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.242-b08, mixed mode)
and maven和行家
mvn -version
Apache Maven 3.6.3
the pom.xml is really large, so I will post the part which I assume is relevant pom.xml 真的很大,所以我会发布我认为相关的部分
<properties>
<java.version>8</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<maven.compiler.release>${java.version}</maven.compiler.release>
<project.build.sourceEncoding>US-ASCII</project.build.sourceEncoding>
<thymeleaf.version>3.0.12.RELEASE</thymeleaf.version>
</properties>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
<include>**/*.html</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.2.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.1</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
</plugin>
</plugins>
I had hoped (not sure if I am doing the right thing) changing from 3.8.1我曾希望(不确定我是否在做正确的事情)从 3.8.1 改变
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
to 3.6.3到 3.6.3
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.3</version>
could solve my issues.可以解决我的问题。 But that doesn't work and end up getting another error
但这不起作用并最终得到另一个错误
Cannot resolve plugin org.apache.maven.plugins:maven-compiler-plugin:3.6.3
How do i get it to build successfully?我如何让它成功构建? I am flexible regarding Java versions.
我对 Java 版本很灵活。 I am allowed to use Java 8 - Java 12, but if possible no changes to the Maven version.
我可以使用 Java 8 - Java 12,但如果可能,不要更改 Maven 版本。 It should stay as is 3.6.3
它应该保持原样 3.6.3
You could write one of both 8 or 1.8 into your java version property to declare Java 8. And using Java 8 you can not use maven.compiler.release
which could be used only with Java 9+您可以将 8 或 1.8 之一写入您的 Java 版本属性以声明 Java 8。并且使用 Java 8 您不能使用
maven.compiler.release
只能与 Java 9+ 一起使用
<java.version>8</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.