1.测试类无法启动
在添加项目依赖时,必须注意Springboot\Springcloud\Springalibaba的版本号对应关系
否则此时类@Test注解的包无法正确导入.
Springboot 2.2以上版本用 org.junit.api org.junit.jupiter.api.Test
2.2以下版本用org.junit.Test
如果没有出现启动按钮
则在测试类和测试方法前加public关键则
有文做详细说明
https://blog.csdn.net/kmesky/article/details/102984592
2.测试类启动 报空指针异常
在启动类添加
@RunWith(SpringRunner.class)注解
注解的意义在于Test测试类要使用注入的类,比如@Autowired注入的类,
有了@RunWith(SpringRunner.class)这些类才能实例化到spring容器中,自动注入才能生效
3.启动类启动失败:java.lang.IllegalStateException: Failed to load property source from ‘file:~application.yml
无法读取yml配置文件,删除注释,settings-File Encodings 全部改为UTF-8
还不行就删除注释