插件[id:'org. springframework. boot',版本号:'2.7.3']未在以下任何来源中找到:

bihw5rsg  于 2022-12-29  发布在  Spring
关注(0)|答案(2)|浏览(218)

我从http://start.spring.io下载了一个新的Spring Boot项目,但出现了错误。请帮助我解决这个问题。
我的build.gradle

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

group = 'com.murprog'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '18'

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

tasks.named('test') {
    useJUnitPlatform()
}

误差

Build file 'D:\java\myblog_grd\build.gradle' line: 2

Plugin [id: 'org.springframework.boot', version: '2.7.3'] was not found in any of the following sources:

* Try:
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Exception is:
org.gradle.api.plugins.UnknownPluginException: Plugin [id: 'org.springframework.boot', version: '2.7.3'] 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.7.3')
  Searched in the following repositories:
    Gradle Central Plugin Repository
cygmwpex

cygmwpex1#

项目的build.gradle文件配置错误,导致了此问题。您应该在build.gradle文件中包含buildscript块,因为build.gradle脚本本身需要它。

zpqajqem

zpqajqem2#

看起来与当前Java版本和sourceCompatibility中提到的版本不一致。在“项目”窗口中打开External Libraries,Java版本应该相同(在您的情况下为< 18 >)。

相关问题