in Spring

Intelli下载Gradle返回Connect Time Out

问题

打开intelliJ项目后,下载Gradle时返回Connect Time Out, 需要对gradle wrapper进行配置。

解决

我的IntelliJthsg版本:

IntelliJ IDEA 2023.2.4 (Community Edition)
Build #IC-232.10203.10, built on October 25, 2023
Runtime version: 17.0.8.1+7-b1000.32 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 11.0
GC: G1 Young Generation, G1 Old Generation
Memory: 4056M
Cores: 12
Registry:
    ide.experimental.ui=true

Non-Bundled Plugins:
    Docker (232.10203.2)
    Lombook Plugin (232.10203.10)
    PythonCore (232.10203.2)

Kotlin: 232-1.9.0-IJ10203.10

1, 查找具体原因, 在IntelliJ中,菜单‘Help’ -> ‘Show Log in Explorer’,具体位置在C:\Users\username \AppData\Local\JetBrains\IdeaIC2023.2\log,查看idea.log文件,找到具体原因,是找不到Gradle的下载地址,设置为了本地一个源,需要设置一个正确的源。
2, 找到具体原因后,找到Gradle Wrapper的配置文件,具体位置为: C:\project_basedir\gradle\wrapper, 修改gradle-wrapper.properties这个配置文件,例如:

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://your_repository_url/repository/gradle/distributions/gradle-8.7-bin.zip
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

注意以上distributionUrl地址要对,可访问, your_repository_url为示例。
问题解决,可以正常下载Gradle并编译。

参考

Stackoverflow: could not install Gradle distribution from ‘https://services.gradle.org/distributions/gradle-2.1-all.zip’
Stackoverflow: How to properly write a gradle-wrapper.properties file?