小编Mag*_*åge的帖子

依赖项中的 JUnit 版本错误

我想在我的 Spring Boot 应用程序上运行 JUnit 5.4+ 测试,以便我可以在我的测试中使用 @Order 注释。但是,无论我尝试什么,Maven 都会将我的 POM 解析为 5.3.2。我已经尝试包括我可以手动想到的所有依赖项,但最终我得到了一堆不匹配的版本。我还尝试清除整个 ~/.m2/repository 文件夹并重建树,结果相同。

mvn依赖的相关部分:树

[INFO] +- org.junit.jupiter:junit-jupiter-api:jar:5.5.0:test
[INFO] |  +- org.apiguardian:apiguardian-api:jar:1.1.0:test
[INFO] |  +- org.opentest4j:opentest4j:jar:1.2.0:test
[INFO] |  \- org.junit.platform:junit-platform-commons:jar:1.3.2:test
[INFO] +- org.junit.jupiter:junit-jupiter:jar:5.5.0:test
[INFO] |  +- org.junit.jupiter:junit-jupiter-params:jar:5.3.2:test
[INFO] |  \- org.junit.jupiter:junit-jupiter-engine:jar:5.3.2:test
[INFO] |     \- org.junit.platform:junit-platform-engine:jar:1.3.2:test
Run Code Online (Sandbox Code Playgroud)

pom.xml 的一部分

<dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>5.5.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <version>5.5.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>junit</groupId>
                    <artifactId>junit</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.9.2</version> …
Run Code Online (Sandbox Code Playgroud)

junit spring maven spring-boot junit5

2
推荐指数
1
解决办法
3079
查看次数

标签 统计

junit ×1

junit5 ×1

maven ×1

spring ×1

spring-boot ×1