Problem
Tests fail.
Example:
mvn install
or
mvn install -U
Causes:
Caused by: java.lang.UnsupportedClassVersionError: br/com/adr/AppTest : Unsupported major.minor version 51.0
Solution
Check the project's java version and plugins, setting the compatible version in pom.xml file.
Follow by the example below.
--------------------------
Before:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
--------------------------
After:
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<jvm>${env.JAVA_HOME7}/bin/java</jvm>
<!-- <jvm>D:/portables_d/jdk-7u25-windows-x64/bin/java</jvm> -->
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
Now, tests section is working.
Additional Tips
Suppose that jvm element is not correctly configured. For instance, using an absolute path, the "java" was missed:
<jvm>D:/portables_d/jdk-7u25-windows-x64/bin</jvm>
So, the plugin can not find the path, and it throws a message like this:
'D:\portables_d\jdk-7u25-windows-x64\bin' is not recognized as an internal or external command, an operable program or a batch file.
Or like this:
More at:
http://sampreshan.svashishtha.com/2012/04/01/quicktip-maven-surefire-plugin-unsupported-major-minor-version-51-0/
https://coderwall.com/p/y8yg8w
No comments:
Post a Comment