mvn test fails because of Surefire JDK version?

后端 未结 3 1967
说谎
说谎 2021-01-12 12:15

I am trying to run mvn test on my project. The project itself compiles and installs but man test fails with the following output:

[ERROR] Failed to execute g         


        
相关标签:
3条回答
  • 2021-01-12 13:05

    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.

    0 讨论(0)
  • 2021-01-12 13:06

    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 :)

    0 讨论(0)
  • 2021-01-12 13:13

    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>
    
    0 讨论(0)
提交回复
热议问题