Spring Boot項目中@SpringBootTest測試的時候卡住,一直Resolving Maven dependencies...


問題

用過idea(筆者經常用2018.3.x)創建 spring boot項目的時候默認會創建一個以下骨架的測試代碼

package com.atguigu;

import org.junit.jupiter.api.Test;

import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
class DemoApplicationTests {

   
    @Test
    void contextLoads() {
        
    }
}

 

當開發人員第一次嘗試測試代碼的時候,會下載Junit5依賴jar包,這個時候就卡死一直沒有辦法后續開發。筆者曾多次遇到這個問題,今天記錄一下

 

 最終被迫無奈結束idea進程。

解決辦法

重啟后在pom.xml添加以下依賴代碼

<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>
<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.11</version>
    <scope>test</scope>
</dependency>

然后重新導入依賴即可。

轉載自:https://blog.csdn.net/qiuyeyijian/article/details/104401631


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM