今天在测试spring和mybatis的时候,报了找不到配置文件

java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: java.lang.IllegalArgumentException: Cannot load an ApplicationContext with a NULL 'contextLoader'. Consider annotating your test class with @ContextConfiguration or @ContextHierarchy.

以上是报错信息,后来发现。

这两句话需要加在测试类上面。

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath*:spring/applicationContext*.xml"})

以上适用于新手

posted on 2019-09-09 16:38  汪汪爱学习  阅读(970)  评论(0编辑  收藏  举报

导航