![](/img/trans.png)
[英]lombok compilation errors when running maven-surefire-plugin:test
[英]Java version issue with maven-surefire-plugin while running mvn test in Jenkins
我嘗試使用 OpenJDK11 在 Jenkins 中構建工件。 首先我運行mvn clean install -DskipTests
& build 成功。
但是當我運行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 兼容。 這是供您閱讀的鏈接。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.