解决springboot 2.2.5 单元测试类的报错
类不存在
原因分析 是junit5升级了 框架没有兼容
解决办法
1 改写pom.xml
<!--测试模块--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.junit.platform</groupId> <artifactId>junit-platform-launcher</artifactId> <version>1.0.1</version> <scope>test</scope> </dependency> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-engine</artifactId> <version>5.0.1</version> <scope>test</scope> </dependency> <dependency> <groupId>org.junit.vintage</groupId> <artifactId>junit-vintage-engine</artifactId> <version>5.5.2</version> <scope>test</scope> </dependency>
测试类
org.junit.jupiter.api.Test;
替换成
import org.junit.Test;
最后的测试单元类
package com.wechat.chat; import org.junit.Test; import org.springframework.boot.test.context.SpringBootTest; @SpringBootTest public class ChatApplicationTests { @Test public void contextLoads() { } }
相关推荐
lustdevil 2020-08-03
zhengzf0 2020-06-21
宿命java 2020-06-15
snowphy 2020-06-06
Julywhj 2020-05-26
AnndyR 2020-05-15
snowphy 2020-05-12
86427019 2020-06-25
Cocolada 2020-11-12
86427019 2020-06-28
84284855 2020-06-11
snowphy 2020-05-30
蛰脚踝的天蝎 2020-11-10
TuxedoLinux 2020-09-11
snowphy 2020-08-19
83540690 2020-08-16
83417807 2020-07-19