Failed to resolve org.junit.platform:junit-platform-launcher:1.5.2解決Spring Boot中關於junit報錯

具體報錯如下:
在這裏插入圖片描述

報這個錯可能根你的網絡有關!

在網上搜了不少解決辦法:最後這個解決辦法最好用。

pom.xml中加入這個依賴:

這是你的測試啓動配置:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <scope>test</scope>
    <exclusions>
        <exclusion>
            <groupId>org.junit.vintage</groupId>
            <artifactId>junit-vintage-engine</artifactId>
        </exclusion>
    </exclusions>
</dependency>

在這個配置下面追加一個依賴:

<!--這裏是你要加的依賴-->
<dependency>
    <!-- this is needed or IntelliJ gives junit.jar or junit-platform-launcher:1.3.2 not found errors -->
    <groupId>org.junit.platform</groupId>
    <artifactId>junit-platform-launcher</artifactId>
    <scope>test</scope>
</dependency>

添加後如下圖:
在這裏插入圖片描述
這時在重新啓動運行測試,就可以成功了!

運行成功如下圖:
在這裏插入圖片描述

小結:如果還不能解決,請檢查你的網絡是否出現故障,可切換網絡試試!
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章