我希望添加一个测试依赖到我的项目,其中使用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似乎不起作用。
任何帮助都将不胜感激。
发布于 2019-08-15 07:50:45
我也遇到过同样的问题,如果依赖项中包含了特定的版本,它就会起作用,例如:
testCompile group: 'org.springframework.security', name: 'spring-security-test', version: '5.1.6.RELEASE'https://stackoverflow.com/questions/36828997
复制相似问题