Gradle不包含传递依赖项

时间:2012-07-15 15:13:46

标签: gradle transitive-dependency spring-test-mvc

我正在尝试使用spring-test-mvc来测试我的小应用程序中的控制器。由于我使用gradle作为构建工具,因此我将依赖项添加到它:

testCompile 'org.springframework:spring-test-mvc:1.0.0.M1'

成功检索spring-test-mvc,并编译测试。但执行测试失败了,因为它似乎不包括像mvc test这样的瞬态依赖。

其中抱怨没找到

org.springframework.mock.web.MockHttpServletRequest

这是spring-test.jar的一部分,它作为spring-test-mvc的pom.xml中的依赖项包含在内https://github.com/SpringSource/spring-test-mvc/blob/master/pom.xml

我可以通过在构建文件中明确地包含依赖项来解决该问题:

testCompile 'org.springframework:spring-test:3.1.1.RELEASE'

但它只会被下一个问题所取代。我试图明确要求瞬态依赖:

testCompile ('org.springframework:spring-test-mvc:1.0.0.M1') {
        transitive = true
    }

但这并不能改变任何事情。

所以问题是:如何让gradle在类路径中包含传递依赖。

注意:传递依赖性似乎在测试之外工作正常。

1 个答案:

答案 0 :(得分:1)

相关问题