亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在以下任何來源中均未找到插件 [id: 'org.springframework.boot',

在以下任何來源中均未找到插件 [id: 'org.springframework.boot',

catspeake 2023-06-08 20:24:44
我最近開始使用 gradle 并嘗試在我的 mac 機器上運行一個帶有 gradle 的 spring boot 應用程序。當我嘗試進行本地構建時,出現以下錯誤:我的 build.gradle 是默認的,它是從 spring initializr 下載的,幾乎沒有依賴項。plugins {id 'org.springframework.boot' version '2.1.7.RELEASE'id 'io.spring.dependency-management' version '1.0.7.RELEASE'id 'java'}group = 'com.ank'version = '0.0.1-SNAPSHOT'sourceCompatibility = '1.8'repositories { maven {    url "https://plugins.gradle.org/m2/" }}dependencies {implementation 'org.springframework.boot:spring-boot-starter-web'implementation 'org.springframework.boot:spring-boot-starter-webflux'testImplementation 'org.springframework.boot:spring-boot-starter-test'testImplementation 'io.projectreactor:reactor-test'}我的 JAVA_HOME 位于路徑:/Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home我已經嘗試在 Intellij、Eclipse 和終端中構建相同的東西gradle --stacktrace。它到處都失敗并出現相同的錯誤。我的 gradle 版本是 5.6。
查看完整描述

3 回答

?
FFIVE

TA貢獻1797條經驗 獲得超6個贊

它在gradlePluginPortal()或 上可用mavenCentral();兩個存儲庫都提供它。當前版本是2.7.1and not2.1.7.RELEASE或某個想象中的不存在的版本2.7.2。
可以看出,2.1.7.RELEASE依賴項存在漏洞,因此最好使用2.7.1.

確保buildscript塊或settings.gradle已定義插件repositories。
我的意思是,那里的這個項目repositories塊(帶有插件存儲庫)實際上是無用的。

準確地說;必須repositories在塊中定義插件buildscript

buildscript {

? ? // Gradle plugin repositories

? ? repositories {

? ? ? ? gradlePluginPortal()

? ? ? ? mavenCentral()

? ? }

? ? // Gradle plugin dependencies

? ? dependencies {}

}

或內部文件settings.gradle:


import org.gradle.api.initialization.resolve.RepositoriesMode


// Gradle plugin repositories

pluginManagement {

? ? repositories {

? ? ? ? gradlePluginPortal()

? ? ? ? mavenCentral()

? ? }

}


// Java project repositories

dependencyResolutionManagement {

? ? repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)

? ? repositories {

? ? ? ? mavenCentral()

? ? }

}

只有這樣plugins模塊中的塊才會知道這些repositories:


// Gradle plugin dependencies

plugins {

? ? id 'org.springframework.boot' version '2.7.1'

? ? id 'io.spring.dependency-management' version '1.0.12.RELEASE'

? ? id 'java'

}


// Java project repositories

// not required when using settings.gradle

repositories {

? ? mavenCentral()

}


// Java project dependencies

dependencies {}


查看完整回答
反對 回復 2023-06-08
?
翻翻過去那場雪

TA貢獻2065條經驗 獲得超14個贊

嘗試將其設置為build.gradle:


plugins {

? id 'org.springframework.boot' version '2.7.2'

? id 'io.spring.dependency-management' version '1.0.12.RELEASE'

? id 'java'

}


group = 'com.example'

version = '0.0.1-SNAPSHOT'

sourceCompatibility = '1.8'


repositories {

? mavenCentral()

}


dependencies {

? implementation 'org.springframework.boot:spring-boot-starter-web'

? implementation 'org.springframework.boot:spring-boot-starter-webflux'

? testImplementation 'org.springframework.boot:spring-boot-starter-test'

? testImplementation 'io.projectreactor:reactor-test'

}


tasks.named('test') {

? useJUnitPlatform()

}


SpringBoot 配置錯誤可以通過檢查生成的文件輕松解決 ->


查看完整回答
反對 回復 2023-06-08
?
慕田峪7331174

TA貢獻1828條經驗 獲得超13個贊

添加以下存儲庫。org.springframework.boot:org.springframework.boot.gradle.plugin在 Maven Central 中不可用:


repositories {

    maven {

      url "https://plugins.gradle.org/m2/"

    }

  }


查看完整回答
反對 回復 2023-06-08
  • 3 回答
  • 0 關注
  • 298 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號