简体   繁体   English

Maven Surefire 测试失败:不支持 class 文件主要版本 61

[英]Maven Surefire test failed: Unsupported class file major version 61

I am trying to create a project in IntelliJ using Maven, but when running mvn install or mvn test in order to run the simple JUnit tests I wrote, it fails with the following error:我正在尝试使用 Maven 在 IntelliJ 中创建一个项目,但是当运行mvn installmvn test以运行我编写的简单 JUnit 测试时,它失败并出现以下错误:

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project Idlearn: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test failed: Unsupported class file major version 61 -> [Help 1]

My pom.xml:我的 pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project>
    <modelVersion>4.0.0</modelVersion>

    <groupId>mimuw</groupId>
    <artifactId>Idlearn</artifactId>
    <version>1</version>
    <name>Idlearn</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <!-- for platform independent encoding-->
        <junit.version>5.8.2</junit.version> <!-- the latest JUnit version -->
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <version>${junit.version}</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.2</version>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>17</source>
                    <target>17</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

I feel like I have tried every possible solution on the web, but to no avail.我觉得我已经尝试了web上所有可能的解决方案,但无济于事。

The problem originally was that my tests wouldn't run.最初的问题是我的测试无法运行。 The command mvn test would output that it was running SomeClassTest however not run any actual tests that it contained (all created just like in many tutorials I found on-line).命令mvn test将 output 它正在运行SomeClassTest但不运行它包含的任何实际测试(所有创建就像我在网上找到的许多教程一样)。 It seems like I was missing maven-surefire and here I am now.好像我错过了maven-surefire ,现在我在这里。

This is what worked for me using Java 17.这就是使用 Java 17 对我有用的方法。

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <dependencies>
        <dependency>
            <groupId>org.ow2.asm</groupId>
            <artifactId>asm</artifactId>
            <version>9.1</version>
        </dependency>
    </dependencies>
</plugin>

And when upgrading to Java 18 this morning, I had to upgrade to asm v9.3 as well.今天早上升级到 Java 18 时,我也必须升级到asm v9.3

I hope it helps.我希望它有所帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 TomEE 8 不支持的类文件主要版本 61 - Unsupported class file major version 61 with TomEE 8 不支持 class 文件主要版本 61 - Unsupported class file major version 61 Maven surefire 插件 2.22.2 构建失败,用于 Junit 5 测试用例,错误不支持 Spring Boot 中的类文件主要版本 56 - Maven surefire plugin 2.22.2 build fails for Junit 5 test cases with errror Unsupported class file major version 56 in spring boot Intellij Maven java.lang.IllegalArgumentException: Unsupported class 文件主要版本 61 并且 Entity 使用不支持的 JDK 编译 - Intellij Maven java.lang.IllegalArgumentException: Unsupported class file major version 61 and Entity was compiled with an unsuppported JDK @SneakyThrows当使用lombok“@SneakyThrows”时,不支持class文件大版本61 - @SneakyThrowsWhen use lombok ”@SneakyThrows“,unsupported class file major version 61 不支持 gradle 的 bootJar 任务的类文件主版本 61 - Unsupported class file major version 61 for gradle's bootJar task dockerBuild 失败导致不受支持的 class 文件主要版本 61 错误 - dockerBuild fails resulting in an unsupported class file major version 61 error IntelliJ gradle 项目错误“不支持的类文件主要版本 61” - IntelliJ gradle project error "Unsupported class file major version 61" 不支持 class 文件主要版本 61 Cordova Mac - Unsupported class file major version 61 Cordova Mac Android Studio 错误“不支持 class 文件主要版本 61” - Android Studio Error "Unsupported class file major version 61"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM