Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Jenkins中运行mvn测试时maven surefire插件出现Java版本问题_Java_Maven_Jenkins_Maven Surefire Plugin_Java 11 - Fatal编程技术网

在Jenkins中运行mvn测试时maven surefire插件出现Java版本问题

在Jenkins中运行mvn测试时maven surefire插件出现Java版本问题,java,maven,jenkins,maven-surefire-plugin,java-11,Java,Maven,Jenkins,Maven Surefire Plugin,Java 11,我尝试用OpenJDK11在Jenkins中构建工件。首先,我运行了mvn clean安装-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 reco

我尝试用OpenJDK11在Jenkins中构建工件。首先,我运行了
mvn clean安装-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
已由较新版本的Java运行时(类文件版本55.0)编译,此版本的Java运行时仅识别52.0以下的类文件版本
org.apache.maven.surefire.booter.SurefireBooterWorkException:分叉进程中出现错误
已由较新版本的Java运行时(类文件版本55.0)编译,此版本的Java运行时仅识别高达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>

11
11
11
maven编译器插件
3.8.0
11
groovy eclipse编译器
config.groovy
org.codehaus.groovy
groovy eclipse编译器
3.0.0-01
org.codehaus.groovy
groovy eclipse批处理
2.5.5-01
org.apache.maven.plugins
maven surefire插件
2.22.1
**/*规格*
请帮助我在詹金斯解决这个问题


注意:我在当地也遇到了类似的问题。我在~/.mavenrc文件中更改了JAVA_主页&问题得到了解决

这只是版本不匹配。您已经使用Java8在本地编译了代码,您的Jenkins有Java11。将本地代码升级到与Java 11兼容的版本。 这是供您阅读的链接


jenkins服务器中可能有多个java版本?您的jenkins项目是如何配置的?使用jenkins管道?我猜maven编译器插件采用了pom.xml中提到的Java版本,而不是maven surefire插件。。有没有办法在maven surefire插件中强制执行java版本?在我在~/.mavenrc文件中更改java_主页后,您可能会寻找使用toolschains.xml的解决方案&问题得到了解决。感谢您的回复。你的发现是正确的。在我在~/.mavenrc文件中更改JAVA_HOME之后,这个问题为我解决了。