简体   繁体   English

Gradle 未下载测试依赖项

[英]Gradle not downloading test dependency

I am looking to add a test dependency to my project which uses gradle.我希望向我的使用 gradle 的项目添加测试依赖项。 What I simply need is for gradle to download the dependency jar so I can import part of the package.我只需要让 gradle 下载依赖 jar,这样我就可以导入部分包。 What I need is the following package:我需要的是以下包:

import org.springframework.security.test.*

So I edited my gradle file to contain所以我编辑了我的 gradle 文件以包含

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
}

I tried building the project after entering this.进入这个后我尝试构建项目。 Unfortunately this didn't work and I cannot import org.springframework.security.test.* I then ran gradlew test which actually had some success and showed:不幸的是,这不起作用,我无法import org.springframework.security.test.*然后我运行了gradlew test ,它实际上取得了一些成功并显示:

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 

Though I have no idea where it downloaded to.虽然我不知道它下载到哪里。 Navigating to $HOME/.gradle/caches/modules-2/files-2.1/org.springframework.security I can see no sign of the downloaded package (and Idea doesn't recognise it in its external libraries).导航到$HOME/.gradle/caches/modules-2/files-2.1/org.springframework.security我看不到下载包的迹象(并且 Idea 在其外部库中无法识别它)。 Running gradle build --refresh-dependencies didn't seem to work.运行gradle build --refresh-dependencies似乎不起作用。
Any help would be very much appreciated.任何帮助将不胜感激。

Closes SO question I could find 关闭了我能找到的问题

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

testCompile group: 'org.springframework.security', name: 'spring-security-test', version: '5.1.6.RELEASE'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM