您的位置: 首页 > 文章 > Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration异常解决方法 Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration异常解决方法 分类: 文章 • 2024-01-22 15:28:52 问题描述 博主今天在编写测试类的时候发生了一个这样的异常(如下图) 起初百度了很久,一直说注解的问题,我也修改了很多方式的注解,但一直没有用,后面自己研究下解决了,具体方法如下 解决方法 第一个原因: 这是我的测试类注解 我将它改成这样就可以了(这里classes=SpringBoot的Application启动类)第二个原因: Java目录下的包名要跟测试包名一致 举个例子: 这里可以在包名后面继续加一些其它的内容,但com.hnu.activiti要有 博主本人就同时遇到了这两个细节错误,有点烦…但最终还是这样解决了。