Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/305.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
“线程中的异常”;“主要”;java.lang.NoClassDefFoundError:org/junit/platform/commons/util/classnamepatterFilterUtils_Java_Junit_Noclassdeffounderror_Junit5_Junit Jupiter - Fatal编程技术网

“线程中的异常”;“主要”;java.lang.NoClassDefFoundError:org/junit/platform/commons/util/classnamepatterFilterUtils

“线程中的异常”;“主要”;java.lang.NoClassDefFoundError:org/junit/platform/commons/util/classnamepatterFilterUtils,java,junit,noclassdeffounderror,junit5,junit-jupiter,Java,Junit,Noclassdeffounderror,Junit5,Junit Jupiter,我想将Maven配置为使用以下依赖项运行Junit 5测试: <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-api</artifactId> <version>5.7.0-M1</version>

我想将Maven配置为使用以下依赖项运行Junit 5测试:

        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>5.7.0-M1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>5.7.0-M1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-params</artifactId>
            <version>5.7.0-M1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-launcher</artifactId>
            <version>1.7.0-M1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-junit-jupiter</artifactId>
            <version>3.3.3</version>
            <scope>test</scope>
        </dependency>

您知道如何解决此问题吗?

我仅使用以下方法解决了此问题:

<dependency>
    <groupId>org.junit</groupId>
    <artifactId>junit-bom</artifactId>
    <version>5.7.0-M1</version>
    <type>pom</type>
</dependency>

org.junit
junit bom
5.7.0-M1
聚甲醛

添加以下代码或maven等效代码:

testRuntimeOnly "org.junit.platform:junit-platform-commons:1.7.0"
解释:

ClassNamePatternFilterUtils属于platfrom commons,它是可传递的依赖项。该类在1.7.0版本中引入。因此,需要明确地添加依赖项。

由于某些原因,在项目构建路径org/junit/platform/commons/util/classnamepatterFilterUtils.class中缺少该依赖项,但可以在junit platform commons(1.7.0)中找到该依赖项

对于maven项目,将此依赖项添加到pom.xml文件:

<dependency>
    <groupId>org.junit.platform</groupId>
    <artifactId>junit-platform-commons</artifactId>
    <version>1.7.0</version>
</dependency>

请显示Maven pom文件的其余部分。第一个猜测:s.t.else正在引入一个不同的版本。我已经看到的是,前4个DEP可以被聚合的artefact junit-jupiter上的单个DEP替换。谢谢,对Me来说效果很好。对于maven依赖项,使用“测试”范围
<dependency>
    <groupId>org.junit.platform</groupId>
    <artifactId>junit-platform-commons</artifactId>
    <version>1.7.0</version>
</dependency>
compile group: 'org.junit.platform', name: 'junit-platform-commons', version: '1.7.0'