[英]Java version issue with maven-surefire-plugin while running mvn test in Jenkins
I tried building artifact in Jenkins with OpenJDK11.我尝试使用 OpenJDK11 在 Jenkins 中构建工件。 First I ran
mvn clean install -DskipTests
& build was successful.首先我运行
mvn clean install -DskipTests
& build 成功。
But when I ran mvn clean install
, I got following error for test classes.但是当我运行
mvn clean install
,测试类出现以下错误。
<CLASS_NAME> has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
org.apache.maven.surefire.booter.SurefireBooterForkException: There was an error in the forked process
<CLASS_NAME> has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
pom.xml pom.xml
<properties>
<java.version>11</java.version>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>11</release>
<compilerId>groovy-eclipse-compiler</compilerId>
<compilerArguments>
<indy/>
<configScript>config.groovy</configScript>
</compilerArguments>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>3.0.0-01</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-batch</artifactId>
<version>2.5.5-01</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<configuration>
<includes>
<include>**/*Spec.*</include>
</includes>
</configuration>
</plugin>
</plugins>
Please help me in fixing this issue in Jenkins请帮助我在 Jenkins 中解决这个问题
Note : I faced similar issue in my local also.注意:我在本地也遇到了类似的问题。 I changed JAVA_HOME in ~/.mavenrc file & the issue got resolved
我在~/.mavenrc文件中更改了 JAVA_HOME & 问题得到解决
This is just a version mismatch.这只是版本不匹配。 You have compiled your code in local using Java 8 and your Jenkins has JAVA 11. Upgrade your local code to Java 11 compatible.
您已经使用 Java 8 在本地编译了代码,并且您的 Jenkins 有 JAVA 11。将您的本地代码升级到 Java 11 兼容。 This is the link for your perusal.
这是供您阅读的链接。
Class has been compiled by a more recent version of the Java Environment 类已由更新版本的 Java 环境编译
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.