问题描述:对Spring MVC项目中的Service层使用JUnit进行测试时出现错误 WebApplicationObjectSupport instance
[ResourceHttpRequestHandler [locations=[class path resource []], resolvers=
[org.springframework.web.servlet.resource.PathResourceResolver@3ce53f6a]]]
does not run in a WebApplicationContext but in: org.springframework.context.support.
GenericApplicationContext@54d901aa: startup date [Thu Mar 22 16:29:56 CST 2018]; root of context hierarchy
错误原因:@ContextConfiguration(locations = { "classpath*:/applicationContext.xml",
"classpath:/spring-mvc.xml"})出错,spring-mvc.xml不应该出现在这里
修正方式:将@ContextConfiguration(locations = { "classpath*:/applicationContext.xml","classpath:/spring-
mvc.xml"})改为@ContextConfiguration(locations = { "classpath*:/applicationContext.xml"})
备注:该文是我在学习JavaEE时遇到问题的备忘录,只针对我创建的工程遇到的问题!!!