我有一台安装了JDK&JRE 6和7的Jenkins服务器.
所有项目都建立在1.6上,除了1.7依赖项目.
我已经将maven pom文件配置为使用JAVA_HOME_7环境PATH中的Java编译器.
<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>
Run Code Online (Sandbox Code Playgroud)
在mvn安装期间,我收到以下错误:
java.lang.RuntimeException: There was an error in the forked process
java.lang.UnsupportedClassVersionError: : Unsupported major.minor version 51.0
Run Code Online (Sandbox Code Playgroud)
我认为这意味着服务器正在使用JRE 1.6.
如何将JRE 1.6与1.7保持在一起以保持与旧1.6项目和新1.7项目的兼容性?
非常感谢,Atanas
我想在我的项目上运行mvn test.项目本身编译和安装,但man测试失败,输出如下:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.18:test (default-test) on project udms-server: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.18:test failed: There was an error in the forked process
[ERROR] java.lang.UnsupportedClassVersionError: some/project/Event : Unsupported major.minor version 52.0
[ERROR] at java.lang.ClassLoader.defineClass1(Native Method)
[ERROR] at java.lang.ClassLoader.defineClass(Unknown Source)
[ERROR] at java.security.SecureClassLoader.defineClass(Unknown Source)
[ERROR] at java.net.URLClassLoader.defineClass(Unknown Source)
[ERROR] at java.net.URLClassLoader.access$100(Unknown Source)
[ERROR] at java.net.URLClassLoader$1.run(Unknown Source)
[ERROR] at java.net.URLClassLoader$1.run(Unknown Source)
[ERROR] at java.security.AccessController.doPrivileged(Native Method)
[ERROR] at java.net.URLClassLoader.findClass(Unknown Source)
[ERROR] at java.lang.ClassLoader.loadClass(Unknown Source)
[ERROR] at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
[ERROR] at …Run Code Online (Sandbox Code Playgroud) 我在我们的应用服务器上运行Junits,该服务器因不支持的major.minor版本51.0而失败.但是,Web应用程序然后构建,部署和运行正常.我不明白这是怎么发生的.我的maven编译器的配置如下所示:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<verbose>true</verbose>
<fork>true</fork>
<source>1.7</source>
<target>1.7</target>
<executable>${JAVA_1_7_HOME}/bin/javac</executable>
<encoding>ISO-8859-1</encoding>
<verbose>true</verbose>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
而我的Junit依赖:
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
<version>4.10</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
任何人都可以想到这是失败的原因吗?