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"})
以上适用于新手