Maven / Jenkins java.lang.UnsupportedClassVersionError:不支持的major.minor版本51.0 [英] Maven/Jenkins java.lang.UnsupportedClassVersionError: Unsupported major.minor version 51.0

查看:245
本文介绍了Maven / Jenkins java.lang.UnsupportedClassVersionError:不支持的major.minor版本51.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一台拥有JDK& ;;的Jenkins服务器。 JRE 6和7安装在一起。

I have a Jenkins server having JDK & JRE 6 and 7 installed together.

所有项目都建立在1.6上,只有1.7依赖。

All of the projects are built on 1.6 except one which is 1.7 dependent.

我已经配置了maven pom文件使用来自JAVA_HOME_7环境PATH的Java编译器。

I've configured the maven pom file to use the Java compiler from the JAVA_HOME_7 environment PATH.

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.0</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                    <showDeprecation>true</showDeprecation>
                    <showWarnings>true</showWarnings>
                    **<executable>${env.JAVA_HOME_7}/bin/javac</executable>**
                    <fork>true</fork>
                    <verbose>false</verbose>
                </configuration>
            </plugin>

在mvn安装期间,我收到以下错误:

During mvn install I'm getting the following error:

java.lang.RuntimeException: There was an error in the forked process
java.lang.UnsupportedClassVersionError: : Unsupported major.minor version 51.0

我认为这意味着服务器正在使用JRE 1.6。

which I think means that the server is using JRE 1.6.

如何将JRE 1.6与1.7保持在一起以保持与旧1.6项目和新1.7项目的兼容性?

How to keep the JRE 1.6 together with 1.7 in order to keep the compatibility with the old 1.6 projects and the new 1.7 one?

非常感谢,
Atanas

Many Thanks, Atanas

推荐答案

您还需要使用java 7运行surefire测试。默认情况下,surefire将使用与运行maven相同的jvm - Java6。

You will need to run surefire tests with java 7 too. By default surefire will use same jvm as that running maven - Java6 in your case.

  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-surefire-plugin</artifactId>
      <version>2.13</version>
      <configuration>
        ...
        <jvm>${env.JAVA_HOME_7}/bin/java</jvm>
      </configuration>
    </plugin>
  </plugins>

这篇关于Maven / Jenkins java.lang.UnsupportedClassVersionError:不支持的major.minor版本51.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆