Python 官方文档:入门教程 => 点击学习
SpringBoot使用test无法启动 test无法启动,遇到 java.lang.IllegalStateException: Unable to find a @spring
test无法启动,遇到
java.lang.IllegalStateException: Unable to find a @springBootConfiguration, you need to use报错信息
测试文件和启动文件是否才同一层目录下
Spring Boot降低了我们对spring开发的难度
采用了大量在的自动配置,我们只需要进行简单的基本配置,就能快速开发一个spring应用。
同样spring对于单元测试也有场景启动器----spring-boot-starter-test,可以让我们在,spring环境下进行测试。
昨天测试的时候,容器都无法启动,检查之后发现了原因,也是因为自己粗心大意。
@RunWith(value = SpringRunner.class)
//@SpringBootTest(classes = SearchApplication9007Test.class) //错误写法 ,这个class应该填写的是你的主启动类,
//而不是你的测试类。以为之前用的稍微高点的版本,可以省略这个括
//号内的配置。但是这个版本需要配置
@SpringBootTest(classes = SearchApplication9007.class) //正确写法 ,应该填入主配置类
public class SearchApplication9007Test{
@Autowired
private elasticsearchTemplate elasticsearchTemplate;
/**
以上为个人经验,希望能给大家一个参考,也希望大家多多支持编程网。
--结束END--
本文标题: Springboot使用test无法启动问题的解决
本文链接: https://www.lsjlt.com/news/154490.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0