Java版本在Jenkins运行MVN测试时与Maven-Surefire-Plugin发行



我尝试使用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 file&amp; amp;中的java_home问题解决了

这只是一个版本不匹配。您已经使用Java 8在本地编译了代码,而Jenkins具有Java 11.将本地代码升级到Java 11兼容。这是您细读的链接。

类是由Java环境的最新版本编译的

相关内容

  • 没有找到相关文章

最新更新