升级Spring Boot后Gradle无法拉取artifactory-java-client-services依赖包
问题:Gradle无法从公司Artifactory拉取已存在的依赖包
我正在为团队的小型项目升级Spring Boot版本,执行命令:
gradlew eclipse -Plocal -Partifactory_username='username' -Partifactory_apikey='password'
时,Gradle无法从公司Artifactory仓库拉取特定包org.jfrog.artifactory.client:artifactory-java-client-services:2.13.0。已确认该包在公司Artifactory网站上存在,但命令执行后提示无法解析该依赖,导入Eclipse时也会报错提示该包缺失。
项目配置信息
build.gradle 内容
buildscript { ext { springBootVersion = '2.6.9' } repositories { maven { url "https://artifactory.trusted.companyName.com/mavenrepo/" credentials { username = project.artifactory_username password = project.artifactory_apikey } } } dependencies { classpath 'org.ajoberstar:grgit:1.7.2' classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") } } apply plugin: 'java' apply plugin: 'eclipse' apply plugin: 'eclipse-wtp' apply plugin: 'maven' apply plugin: 'maven-publish' apply plugin: 'org.springframework.boot' if (project.hasProperty("projVersion")) { version = project.projVersion } else { version = "0.0-SNAPSHOT" } group = 'CoreConfigBackend' // In this section you declare where to find the dependencies of your project repositories { maven { url "https://artifactory.trusted.companyName.com/companyNamecommonssecurity-maven-virtual/" credentials { username = project.artifactory_username password = project.artifactory_apikey } } maven { url "https://artifactory.trusted.companyName.com/mavenrepo/" credentials { username = project.artifactory_username password = project.artifactory_apikey } } maven { url "https://artifactory.trusted.companyName.com/coreconfig_commons-snapshots/" credentials { username = project.artifactory_username password = project.artifactory_apikey } } } configurations { all*.exclude module : 'spring-boot-starter-logging' } dependencies { if (project.hasProperty("local")) { compile project(':CommonUtility') } else { compile(group: 'CoreConfigBackend', name: 'CommonUtility', version: version){ changing = true } } compile('org.springframework.boot:spring-boot-starter-web:2.6.9') compile('org.springframework:spring-tx:5.3.22') compile 'org.springframework.boot:spring-boot-starter-jdbc:2.6.9' compile('com.github.ulisesbocchio:jasypt-spring-boot:2.1.0') compile 'org.springframework.boot:spring-boot-starter-data-mongodb:2.6.9' compile ("commons-lang:commons-lang:2.6") compile 'com.fasterxml.jackson.core:jackson-core:2.9.4' compile 'com.fasterxml.jackson.core:jackson-annotations:2.9.4' compile 'com.fasterxml.jackson.core:jackson-databind:2.9.4' compile 'org.jfrog.artifactory.client:artifactory-java-client-services:2.13.0' // Log4j 2 compile ('org.apache.logging.log4j:log4j-core:2.17.1') compile ('org.apache.logging.log4j:log4j-api:2.17.1') compile ('org.apache.logging.log4j:log4j-slf4j-impl:2.17.1') // Use JUnit test framework testImplementation 'junit:junit:4.12' } bootJar { exclude ("application.properties") exclude ("database.properties") exclude ("artifactory.properties") } task setupProject { doFirst { File dir = new File("$buildDir/../../../coreconfig_commons") if(!dir.exists()) { def grgit = org.ajoberstar.grgit.Grgit.clone(dir: "$buildDir/../../../companyName_commons", uri: "https://stash.trusted.companyName.com:7990/scm/cor1dca/companyName_commons.git") } } } publishing { publications { mavenJava(MavenPublication) { from components.java } } }
gradle-wrapper.properties 内容
distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip
命令执行输出
> Task :eclipseClasspath Could not resolve: org.jfrog.artifactory.client:artifactory-java-client-services:2.13.0 Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0. Use '--warning-mode all' to show the individual deprecation warnings. See https://docs.gradle.org/6.8/userguide/command_line_interface.html#sec:command_line_warnings BUILD SUCCESSFUL in 33s 10 actionable tasks: 10 executed
Gradle版本信息
gradlew -v ------------------------------------------------------------ Gradle 6.8 ------------------------------------------------------------ Build time: 2021-01-08 16:38:46 UTC Revision: b7e82460c5373e194fb478a998c4fcfe7da53a7e Kotlin: 1.4.20 Groovy: 2.5.12 Ant: Apache Ant(TM) version 1.10.9 compiled on September 27 2020 JVM: 1.8.0_361 (Oracle Corporation 25.361-b31) OS: Windows 10 10.0 amd64
排查与解决建议
- 检查仓库权限:确认当前账号对存放
org.jfrog.artifactory.client:artifactory-java-client-services:2.13.0的Artifactory仓库有读取权限,即使包显示存在,权限不足也会导致拉取失败。 - 验证仓库URL:确认该包实际所在的仓库是否已添加到
repositories块中。比如检查Artifactory中该包的存储路径,是否对应你配置的mavenrepo或其他仓库URL。 - 清理Gradle缓存:执行
gradlew clean build --refresh-dependencies强制刷新依赖,避免本地缓存的无效记录干扰。 - 检查依赖坐标正确性:再次核对包的groupId、artifactId、版本号是否与Artifactory中的完全一致,注意大小写和特殊字符。
- 测试单独拉取依赖:创建一个极简的Gradle项目,只添加该依赖和对应的Artifactory仓库配置,测试是否能正常拉取,排除项目其他配置的干扰。
- 检查代理或网络:确认本地网络能正常访问公司Artifactory仓库,无代理拦截或防火墙限制。
内容的提问来源于stack exchange,提问作者waffledood
相关产品推荐
相关产品推荐

