我从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
2条答案
按热度按时间cygmwpex1#
项目的
build.gradle
文件配置错误,导致了此问题。您应该在build.gradle
文件中包含buildscript
块,因为build.gradle
脚本本身需要它。zpqajqem2#
看起来与当前Java版本和
sourceCompatibility
中提到的版本不一致。在“项目”窗口中打开External Libraries
,Java版本应该相同(在您的情况下为< 18 >
)。