错误详细:java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @Context

解决办法一

因为测试类所在包和springboot主启动类不在同一目录下导致,可以把测试类放在和springboot主启动类同一包下。

解决办法二

修改目录结构如图
springboot junit 单元测试 报 Unable to find a @SpringBootConfiguration, you need to use @Context
把刚创建的包设置为Test Sources Root,运行测试类就成功了springboot junit 单元测试 报 Unable to find a @SpringBootConfiguration, you need to use @Context

相关文章:

  • 2022-12-23
  • 2022-01-15
  • 2021-09-23
  • 2022-12-23
猜你喜欢
  • 2021-04-20
  • 2021-09-08
  • 2021-05-06
  • 2021-10-10
相关资源
相似解决方案