mvn test fails because of Surefire JDK version?

余生颓废 提交于 2019-11-29 10:54:55

Make sure your version of Maven runtime >= JRE 1.8.

Run java -version in console to check the version, if mvn command is executed in console too. Alternatively to change maven JRE in your IDE, if maven is executed in IDE.

UnsupportedClassVersionError:

Thrown when the Java Virtual Machine attempts to read a class file and determines that the major and minor version numbers in the file are not supported.

The JVM shall be explicitly set in the plugin configuration.

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

It seems I hadn't updated my Maven in Eclipse (right click project -> Maven -> Update Project...) or chosen JDK 8 in Window -> Preferences -> Java -> Compiler options. With these two done everything works perfectly again :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!