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>