You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Gradle无法下载com.netflix.graphql.dgs相关Jar包问题求助

Gradle无法下载com.netflix.graphql.dgs系列构件的问题

我遇到Gradle无法下载com.netflix.graphql.dgs:*.jar构件的问题,这些构件在Maven中央仓库中确实存在。

Gradle已在本地缓存中创建了对应的版本目录,但目录内只有.pom和.module文件,没有实际的.jar包或源码jar包。

本地缓存目录结构示例:

C:\Users\abc\.gradle\caches\modules-2\files-2.1\com.netflix.graphql.dgs\graphql-dgs-client>dir
 Volume in drive C is Windows
 Volume Serial Number is 6666-0C00

 Directory of C:\Users\abc\.gradle\caches\modules-2\files-2.1\com.netflix.graphql.dgs\graphql-dgs-client

07/25/2023  01:27 AM    <DIR>          .
07/25/2023  01:27 AM    <DIR>          ..
07/24/2023  11:55 PM    <DIR>          4.9.15
07/24/2023  11:16 PM    <DIR>          6.0.0
07/25/2023  12:52 AM    <DIR>          6.0.1
07/25/2023  01:27 AM    <DIR>          7.0.0
07/24/2023  11:40 PM    <DIR>          7.3.0
07/24/2023  11:13 PM    <DIR>          7.3.2
               0 File(s)              0 bytes
               8 Dir(s)  23,834,460,160 bytes free

以7.0.0版本为例,缓存目录内无jar包:

C:\Users\abc\.gradle\caches\modules-2\files-2.1\com.netflix.graphql.dgs\graphql-dgs-client\7.0.0>dir /s
 Volume in drive C is Windows
 Volume Serial Number is 6666-0C00

 Directory of C:\Users\abc\.gradle\caches\modules-2\files-2.1\com.netflix.graphql.dgs\graphql-dgs-client\7.0.0

07/25/2023  01:27 AM    <DIR>          .
07/25/2023  01:27 AM    <DIR>          ..
07/25/2023  01:27 AM    <DIR>          5c56063934776448d4bf3c263329e17a3d16fcca
07/25/2023  01:27 AM    <DIR>          6bcd39f7d317f7cf7995c7581d5309d87da6e656
               0 File(s)              0 bytes

 Directory of C:\Users\abc\.gradle\caches\modules-2\files-2.1\com.netflix.graphql.dgs\graphql-dgs-client\7.0.0\5c56063934776448d4bf3c263329e17a3d16fcca

07/25/2023  01:27 AM    <DIR>          .
07/25/2023  01:27 AM    <DIR>          ..
07/25/2023  01:27 AM             5,625 graphql-dgs-client-7.0.0.pom
               1 File(s)          5,625 bytes

 Directory of C:\Users\abc\.gradle\caches\modules-2\files-2.1\com.netflix.graphql.dgs\graphql-dgs-client\7.0.0\6bcd39f7d317f7cf7995c7581d5309d87da6e656

07/25/2023  01:27 AM    <DIR>          .
07/25/2023  01:27 AM    <DIR>          ..
07/25/2023  01:27 AM             7,251 graphql-dgs-client-7.0.0.module
               1 File(s)          7,251 bytes

     Total Files Listed:
               2 File(s)         12,876 bytes
               8 Dir(s)  23,834,071,040 bytes free

IntelliJ中收到的错误提示:

myprj:test: Could not resolve com.netflix.graphql.dgs:graphql-dgs-client:6.0.2.
Required by:
    project :

Possible solution:
 - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html

环境信息

  • Windows 10
  • gradlew 8.1.1
  • Java 11

注:apache httpclient、mysql-connector-j等其他构件可正常下载。

build.gradle配置

plugins {
    id 'org.springframework.boot' version '2.3.2.RELEASE'
    id 'io.spring.dependency-management' version '1.0.9.RELEASE'
    id 'java'
}

group = 'com.abc'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-web'
    testImplementation('org.springframework.boot:spring-boot-starter-test') {
        exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
    }
    implementation group: 'com.netflix.graphql.dgs', name: 'graphql-dgs-client', version: '6.0.2'
    implementation 'com.netflix.graphql.dgs:graphql-dgs-extended-scalars:7.2.0'
    implementation 'com.mysql:mysql-connector-j:8.1.0'

}

test {
    useJUnitPlatform()
}

解决方案

1. 确认依赖版本有效性

先核实graphql-dgs-client:6.0.2是否确实在Maven中央仓库存在,若版本不存在,替换为已发布的稳定版本(如6.0.1、7.0.0等)。

2. 清理缓存并强制刷新依赖

执行命令清理缓存并重新构建:

gradlew clean build --refresh-dependencies

也可手动删除本地缓存目录C:\Users\abc\.gradle\caches\modules-2\files-2.1\com.netflix.graphql.dgs,再重新执行构建操作。

3. 规避Spring Boot依赖管理覆盖

Spring Boot的dependency-management插件可能会覆盖依赖版本,可通过以下方式强制指定版本:

dependencyManagement {
    dependencies {
        dependency 'com.netflix.graphql.dgs:graphql-dgs-client:6.0.2'
        dependency 'com.netflix.graphql.dgs:graphql-dgs-extended-scalars:7.2.0'
    }
}

或者在依赖声明中添加force = true:

implementation group: 'com.netflix.graphql.dgs', name: 'graphql-dgs-client', version: '6.0.2', force: true

4. 补充Netflix相关仓库(可选)

部分版本可能优先发布在Netflix关联仓库,可在repositories块中添加:

repositories {
    mavenCentral()
    maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
}

5. 检查网络代理配置

若使用网络代理,确保Gradle代理配置正确,在gradle.properties中添加:

systemProp.http.proxyHost=你的代理地址
systemProp.http.proxyPort=你的代理端口
systemProp.https.proxyHost=你的代理地址
systemProp.https.proxyPort=你的代理端口

内容的提问来源于stack exchange,提问作者CodeBot

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.15 06:54:53