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