記錄一個由 gradle 構建項目遇到的問題:
起因:項目原先運行正常,不過個人 移除掉默認倉庫 .gradle 倉庫後,重新拉取報錯如下:
FAILURE: Build failed with an exception.
* Where:
Build file 'F:\ideaSpace\insuranceService\build.gradle' line: 13
* What went wrong:
Plugin [id: 'org.springframework.boot', version: '2.2.4.RELEASE'] was not found in any of the following sources:
- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'org.springframework.boot:org.springframework.boot.gradle.plugin:2.2.4.RELEASE')
Searched in the following repositories:
Gradle Central Plugin Repository
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 0s
19:10:18: Task execution finished 'clean'.
這是 build.gradle 文件的內容
buildscript {
repositories {
maven {
url "http://maven.aliyun.com/nexus/content/groups/public"
}
maven {
url 'https://maven.aliyun.com/repository/gradle-plugin'
}
}
}
plugins {
id 'org.springframework.boot' version '2.2.4.RELEASE'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
id 'java'
}
網上查詢大多說是插件引用不對:
以下羅列出找到的2個方法(針對我的項目都無法解決,期望對查閱者有幫助),還有第三種,是摸索出來的,可解決(請各位對症下藥)
第一種:修改插件引用形式
https://blog.triplez.cn/err-and-solution-of-config-gradle-idea-env/
第二種:下載插件引用不到的情況
* What went wrong:
A problem occurred configuring root project 'MyApp'.
> Could not resolve all files for configuration ':classpath'.
> Could not download jimfs.jar (com.google.jimfs:jimfs:1.1)
> Could not get resource 'https://plu
https://www.codercto.com/a/50093.html
第三種:需要查看你本地用的JDK,是 一般的JDK 還是 OpenJDK, 如果是用OpenJDK,請切換到一般的JDK,,並把項目目錄下的 .idea 內 workspace.xml 刪除 , 並把項目 clean (不能clean,則手動移除項目目錄下生成的構建包 .build 、 .gradle、out )
關閉重啓,重新拉取,就OK。
原因具體不太清楚,OpenJDK 安裝在 mac電腦 可以直接拉取,在windows環境,經常會錯出這類錯誤