• java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=…) with your test
  • 非法状态异常:无法找到@SpringBootConfiguration,您需要在测试中使用@ContextConfiguration 或@SpringBootTest(classes=…)

很明显,给出了解决方案,加载配置文件,如下

有两种方式

第一种:@SpringBootTest(classes = MallProjectApplication.class)
第二种:

@SpringBootTest
@ContextConfiguration(classes = MallProjectApplication.class)

Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(相关推荐

  1. SpringBoot测试失败并报错: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration

    情况一: 该测试类在测试包test下的包名和类路径java下的包名不一致导致的,修改包名一致即可 由于包名自动生成的缘故导致这两个包名不一致,引发以下报错 java.lang.IllegalState ...

  2. SpringBoot Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration

    如果只是为了查看springboot的版本等公共方法,直接在classes加上当前类 @SpringBootTest(classes = xxx.class) 经典解读: springboot单元测试 ...

  3. 解决SpringBoot测试时出现:Unable to find a @SpringBootConfiguration,you need to use @ContextConfiguration

     在测试类中找不到带有@SpringBootApplication的启动类.  运行TestMy类的test1()方法,报错.并且book出现了红色下划线.  解决.将测试类的路径和Applicati ...

  4. java.lang.IllegalStateException Unable to find a @SpringBootConfiguration错误解决方案(亲测)

    问题描述: java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @C ...

  5. Spring 测试运行的时候提示 Unable to find a @SpringBootConfiguration 错误

    Spring 进行测试的时候提示的错误信息如下: SEVERE: Caught exception while closing extension context: org.junit.jupiter ...

  6. Spring Boot——[java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration]解决方案

    问题描述 问题分析 没在根目录下写一个Spring Boot的启动类. 解决方案 方案一:Class 在根目录下写一个Spring Boot的启动类. 方案二:注解  需要在注解上加上 @Spring ...

  7. SpringBoot Unable to find a @SpringBootConfiguration, you need to use....

    错误原因 启动项与test不在同级根目录下 解决办法 将启动项与test各自放到相同根目录下

  8. java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @Contex

    报这个错,是因为测试包名和项目包名不一致导致的.

  9. spring boot注释_Spring Boot中的@SpringBootConfiguration注释

    spring boot注释 Spring Boot中的 @SpringBootConfiguration注释是一个类级别的注释,它指示此类提供了应用程序配置. 通常,具有main()方法的类最适合此注 ...

  10. Spring Boot中的@SpringBootConfiguration注释

    Spring Boot中的 @SpringBootConfiguration注释是一个类级别的注释,它指示此类提供了应用程序配置. 通常,具有main()方法的类最适合此注释. 我们通常使用@Spri ...

最新文章

  1. C# 使用HttpWebRequest提交ASP.NET表单并保持Session和Cookie
  2. 1013 Battle Over Cities(并查集解法)
  3. 你的机器学习模型为什么会出错?奉上四大原因解析及五条改进措施
  4. 伯克利在《我的世界》举办虚拟毕业典礼,致辞、抛礼帽一样不少!
  5. linux存储--虚拟内存详解MMU、页表(十)
  6. thinkphp如何跨模块调用方法呢?
  7. VTK:vtkBorderWidget用法实战
  8. python课后题答案第一章_Python程序设计课后习题答案-第一单元
  9. SQL知识(浓缩版)快速入门(基础语法、概念)
  10. android linkedin 登陆授权及分享
  11. 生产制造MES系统源码 采购管理模块解析
  12. SCDM学习笔记(2)
  13. 《数据结构》第十一篇、线性表中的链式存储结构--循环链表
  14. RocketMQ Topic是如何注册和保存的
  15. 点线面的意义_聊聊「点线面」的概念
  16. 韩国大面积断网,电信公司KT承认其配置错误,此前甩锅DDoS攻击
  17. 上网课用哪种耳机好、长时间听网课耳机推荐
  18. 生化危机5:惩罚 感
  19. 【计算机网络复习】408王道视频总结 第六章:应用层
  20. 使用LL库开发STM32:概述与使用

热门文章

  1. 从头认识java-16.4 nio的读与写(ByteBuffer的使用)
  2. sping加载bean都发生了些什么
  3. Atitit Mysql查询优化器 存取类型 范围存取类型 索引存取类型 AND or的分析
  4. linux log4j 使用
  5. memberfieldRedis操作 hash sort String sorted_set list help @String @list
  6. 页面指令JSP常见的指令有哪些?(面试必备)
  7. 拓端tecdat|时间序列建模三部曲
  8. spring5.0学习笔记9
  9. MatConvNet 相关函数解释说明
  10. 【论文笔记】Rich feature hierarchies for accurate object detection and semantic segmentation