Spring MVC Controller测试报WebApplicationContext is required

来源:互联网 发布:有好看衣服的淘宝店铺 编辑:程序博客网 时间:2024/05/20 06:56

我在用Spock做Spring MVC Controller测试时,总是报webapplicationcontext无法找到,我在代码里已经标注了@WebAppConfiguration,但是application文件确实没有加载。后来查找知道原因是因为用Spock测试框架时,没有

加载相应的jar包spock-spring-1.0-groovy-2.4.jar.


java.lang.IllegalArgumentException: WebApplicationContext is required

at org.springframework.util.Assert.notNull(Assert.java:115)
at org.springframework.test.web.servlet.setup.DefaultMockMvcBuilder.<init>(DefaultMockMvcBuilder.java:52)

at org.springframework.test.web.servlet.setup.MockMvcBuilders.webAppContextSetup(MockMvcBuilders.java:47)





0 0
原创粉丝点击