Java maven-surefire-plugin 的版本问题,而 运行 Jenkins 中的 mvn 测试
Java version issue with maven-surefire-plugin while running mvn test in Jenkins
我尝试使用 OpenJDK11 在 Jenkins 中构建工件。首先我 运行 mvn clean install -DskipTests
& 构建成功。
但是当我 运行 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
<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>
请帮助我解决 Jenkins 中的这个问题
注意:我在本地也遇到过类似的问题。我在 ~/.mavenrc 文件中更改了 JAVA_HOME 并且问题得到解决
这只是版本不匹配。您已经使用 Java 8 在本地编译了您的代码,并且您的 Jenkins 具有 JAVA 11。将您的本地代码升级到 Java 11 兼容。
这是供您阅读的 link。
我尝试使用 OpenJDK11 在 Jenkins 中构建工件。首先我 运行 mvn clean install -DskipTests
& 构建成功。
但是当我 运行 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
<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>
请帮助我解决 Jenkins 中的这个问题
注意:我在本地也遇到过类似的问题。我在 ~/.mavenrc 文件中更改了 JAVA_HOME 并且问题得到解决
这只是版本不匹配。您已经使用 Java 8 在本地编译了您的代码,并且您的 Jenkins 具有 JAVA 11。将您的本地代码升级到 Java 11 兼容。 这是供您阅读的 link。