我正在尝试使用spring-test-mvc在我的小应用程序中测试控制器。由于我使用gradle作为构建工具,因此我将依赖项添加到其中,如下所示:
testCompile 'org.springframework:spring-test-mvc:1.0.0.M1'它成功地检索了spring-test-mvc,并编译了测试。但是执行测试失败了,因为它似乎不包含像mvc测试那样的瞬态依赖。
在其他方面,它抱怨没有找到
org.springframework.mock.web.MockHttpServletRequest作为spring-test-mvc的pom.xml https://github.com/SpringSource/spring-test-mvc/blob/master/pom.xml中的一个依赖项,它是spring-test.jar的一部分。
我可以通过在构建文件中明确地包含依赖项来修复这个问题:
testCompile 'org.springframework:spring-test:3.1.1.RELEASE'但它只是被下一个问题所取代。我试图显式地请求瞬时依赖关系:
testCompile ('org.springframework:spring-test-mvc:1.0.0.M1') {
transitive = true
}但这并不能改变任何事情。
所以问题是:如何让gradle在类路径中包含传递依赖关系。
注意:传递依赖似乎可以在测试之外很好地工作。
发布于 2012-07-16 00:00:21
这是POM的问题。http://repo.springsource.org/libs-milestone/org/springframework/spring-test-mvc/1.0.0.M1/spring-test-mvc-1.0.0.M1.pom不声明任何依赖项。
https://stackoverflow.com/questions/11493064
复制相似问题