【问题标题】:Gradle not downloading test dependencyGradle没有下载测试依赖项
【发布时间】:2016-08-18 03:51:33
【问题描述】:

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

import org.springframework.security.test.*

所以我编辑了我的 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
}

进入后我尝试构建项目。不幸的是,这不起作用,我不能 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 

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

Closes SO question I could find

【问题讨论】:

  • 4.04 是我在 Maven 存储库中看到的最新版本...但是我看不出你所做的有什么问题,因为它明确表示已下载
  • 您的问题或问题究竟是什么?你需要下载的 JAR 的物理位置做什么?
  • @BjörnKautler 它说下载的依赖项(使用gradlew)但我找不到也无法使用spring-security-test
  • 你没有回答我的任何问题。你需要下载的JAR的物理位置有什么用,如果你使用它有什么问题。你如何使用它?你得到什么错误? ...?
  • 顺便说一句。 afair --refresh-dependencies 只是忘记了它是否在哪个存储库中找到了什么并重新看起来。因此,如果它没有在特定存储库中的特定版本中找到一个 dep,那么 gradle 可能会记住这一点并需要 --refresh-dependencies 再次查看存储库。与重新下载依赖无关。

标签: java gradle spring-security-test


【解决方案1】:

我遇到了同样的问题,如果依赖项中包含特定版本,它就可以工作,例如:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-15
    • 2018-08-29
    • 2021-12-18
    • 1970-01-01
    • 2015-03-20
    • 2011-07-05
    • 2020-04-30
    相关资源
    最近更新 更多