You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Gradle初始化脚本中无法应用Spring Boot插件问题求助

Fix: "Plugin with id 'org.springframework.boot.gradle.plugin.SpringBootPlugin' not found" in Gradle Init Script

Let's break down what's going wrong here and fix it step by step:

The Core Issue

You're trying to apply the Spring Boot Plugin using its full Java class name (org.springframework.boot.gradle.plugin.SpringBootPlugin) instead of its official Gradle plugin ID. Gradle uses plugin IDs to resolve and apply plugins, not the full class path.

Corrected Init Script

Here's the adjusted version of your init script that should work:

initscript {
    repositories {
        gradlePluginPortal()
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:2.5.1")
    }
}

allprojects {
    apply plugin: "java"
    apply plugin: "application"
    // Use the official plugin ID instead of the full class name
    apply plugin: "org.springframework.boot"
    // Optional: Add dependency management plugin to handle Spring Boot BOM
    apply plugin: "io.spring.dependency-management"

    repositories {
        gradlePluginPortal()
        mavenCentral()
    }
}

Key Explanations

  1. Plugin ID vs Class Name: The Spring Boot Plugin's standard ID is org.springframework.boot — this is what Gradle expects when using apply plugin:. The full class name is only used in specific scenarios (like custom plugin implementations), not for official plugins from the portal.
  2. Dependency Management Plugin: Adding io.spring.dependency-management is optional but highly recommended. It automatically imports Spring Boot's Bill of Materials (BOM), which manages consistent versions for all Spring Boot-related dependencies, so you don't have to specify versions manually.
  3. Version Compatibility: Double-check that your Gradle version is compatible with Spring Boot 2.5.1. This plugin version requires Gradle 6.8.x to 7.3.x. Run ./gradlew --version to verify your installed Gradle version.

Quick Troubleshooting

  • If you still see issues, confirm your network can access gradlePluginPortal() and mavenCentral() — sometimes corporate proxies or firewalls block these repositories.
  • Clear your Gradle cache (usually in ~/.gradle/caches) and try running your build again to rule out corrupted cached dependencies.

内容的提问来源于stack exchange,提问作者Mox

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.29 00:17:43