首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Gradle不下载测试依赖项

Gradle不下载测试依赖项
EN

Stack Overflow用户
提问于 2016-04-25 05:16:54
回答 1查看 1.8K关注 0票数 4

我希望添加一个测试依赖到我的项目,其中使用gradle。我只需要gradle下载依赖jar,这样我就可以导入包的一部分。我需要的是以下包:

代码语言:javascript
复制
import org.springframework.security.test.*

所以我编辑了我的gradle文件以包含

代码语言:javascript
复制
dependencies {
    compile('org.springframework.boot:spring-boot-starter-data-jpa')
    compile('org.springframework.boot:spring-boot-starter-security')
    compile('org.springframework.boot:spring-boot-starter-thymeleaf')
    runtime('org.hsqldb:hsqldb')
    testCompile('org.springframework.boot:spring-boot-starter-test')
    testCompile('org.springframework.security:spring-security-test') // This is what I added to try and download the new dependency
}

在进入这个项目后,我尝试构建该项目。不幸的是,这不起作用,我不能import org.springframework.security.test.*,然后我运行了gradlew test,它确实取得了一些成功,并显示:

代码语言:javascript
复制
Download https://repo1.maven.org/maven2/org/springframework/security/spring-security-test/4.0.3.RELEASE/spring-security-test-4.0.3.RELEASE.pom
Download https://repo1.maven.org/maven2/org/springframework/security/spring-security-test/4.0.3.RELEASE/spring-security-test-4.0.3.RELEASE.jar 

虽然我不知道它下载到哪里去了。导航到$HOME/.gradle/caches/modules-2/files-2.1/org.springframework.security,我看不到下载的包的迹象( Idea无法在其外部库中识别它)。运行gradle build --refresh-dependencies似乎不起作用。

任何帮助都将不胜感激。

Closes SO question I could find

EN

回答 1

Stack Overflow用户

发布于 2019-08-15 07:50:45

我也遇到过同样的问题,如果依赖项中包含了特定的版本,它就会起作用,例如:

代码语言:javascript
复制
testCompile group: 'org.springframework.security', name: 'spring-security-test', version: '5.1.6.RELEASE'
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36828997

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档