当我的测试类作为 JUnit Test 运行时,控制台显示:
INFO: Neither @ContextConfiguration nor @ContextHierarchy found for test class [com.package.mvc.AccountControllerTestDoc]
但是我的类(com.package.mvc.AccountControllerTestDoc)看起来像:
...
@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@ContextConfiguration("classpath*:business-config.xml")
public class AccountControllerTestDoc {
...
}
为什么没找到?这里使用Spring 4.2.2。
最佳答案
我的看起来像这样:
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = MyLoggingdemoApplication.class)
@WebAppConfiguration
public class MyLoggingdemoApplicationTests {
关于spring - Spring MVC 应用程序测试中的 ContextConfiguration,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38640676/