今天在springboot项目中做单元测试时候用到@Test时,总是卡在加载Resolving Juint-platform-engine/1.6.2........中,然后一直加载不出来,着实让人上火。关键是:还取消不掉!!!!无奈只能强制关闭IDEA软件。
查看了网上多种解决方法,我也是挨个都试了遍,就一种方法成功了,因此,在这里写个文为大家总结一下这个坑的各种解决方案,方案千万种,总有一种适合你,愿下辈子没有bug(巴拉巴拉)。
- 解决方案1:(本人服用后效果甚佳)
引入以下依赖即可,据说是IDEA与junit5的的一个bug问题。简直尼玛是神级坑!
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<scope>test</scope>
</dependency>
解决方案2:(本人然并卵)
打开Settings ,修改maven Importing的jvm参数, 默认为700多, 直接修改成 -Xms1024m -Xmx2048m。
解决方案3: (服用后和方案1效果差不多,还少导一个包,或许本身就有呢~)
重启后在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>
解决方案4:(本人然并卵)
更换到阿里云镜像服务器。修改maven配置文件 $M2_HOME/conf/settings.xml (也可以在用户 home 目录 .m2 下面添加一个 settings.xml 文件),添加:
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>*</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
Tips: 之所以会试这么多种方法纯粹是运气不好,看看方案1多简介明了,要是运气好首先用那种方法立马就成功了呢!
如果有其他新的方法欢迎评论留言交流哦,还好我是跳出坑了哈哈!