解決 Gradle 無法導入套件問題

4年前 (2019-11-25) Yosheng 程式設計 0評論 已收錄 4865℃

最近開始複習以前寫過的項目,不知道是不是環境改變,開啟項目後無法正常執行項目裡面的Gradle腳本,經過推敲測試總算解決問題,以下開始記錄

遇到的錯誤訊息如下

* What went wrong:
Plugin [id: 'org.springframework.boot', version: '2.1.6.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.1.6.RELEASE')
Searched in the following repositories:
maven(http://maven.aliyun.com/nexus/content/groups/public/)
MavenRepo

方法1: 修改 build.gradle

參考 配置 Gradle (IDEA) 环境的坑 這篇文章 需要修改 build.gradle 文件中 plugins 從下述

改為

最後在 build.gradle 文件最前面加入 如下配置

即可正常匯入項目並自動導入引用

方法2: 修改 settings.gradle

參考 Gradle Core Plugins (plugin is not in 'org.gradle' namespace) 解決問題

找到 settings.gradle 並在最底下加入 如下配置

雖然 Build Configuration 會通過,但依賴並沒有正常導入,推測可能是 Kotlin 有關,反正無法解決問題。

博主

擅長使用 C# 和 Java 開發項目,全棧開發工程師,前端主要使用 Vue 其次 Angular ,目前正在學習分布式架構,運維研發兼具,平時愛好鑽研技術並應用於實務當中,常駐於上海。

相關推薦

相逢就是有緣,留下足跡吧!