Rade Milovic
Rade Milovic

Reputation: 1015

spring-boot gradle plugin can't be found

I have a separate gradle script that is just adding spring-boot plugin. It looks like this:

buildscript {
    repositories {
        mavenLocal()
        mavenCentral()
        maven { url 'http://repo.spring.io/libs-release' }
    }
    dependencies {
        classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.1.8.RELEASE'
    }
}

apply plugin: 'spring-boot'

Then, in another project, it is referenced like this:

apply from: '../../food-orders-online-main/spring-boot.gradle'

When I run build task I'm getting the following error:

A problem occurred evaluating script.
> Failed to apply plugin [id 'spring-boot']
> Plugin with id 'spring-boot' not found.

Someone knows what I'm doing wrong?

Upvotes: 43

Views: 136105

Answers (11)

so-random-dude
so-random-dude

Reputation: 16555

Whoever comes here in 2024+, do yourself a favor, go to the spring starter (spring boot template generating tool) start.spring.io and generate a template project from there, and build step-by-step from there. Change/add one variable at a time and check it.

Original Answer

These are the Plugins that I am using on spring boot 2.0.1

apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

My complete vanilla gradle file here (Spring boot 2.0.5)

buildscript {
    ext {
        springBootVersion = '2.0.5.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8

repositories {
    mavenCentral()
}


dependencies {
    compile('org.springframework.boot:spring-boot-starter')
    testCompile('org.springframework.boot:spring-boot-starter-test')
}

Upvotes: 17

Md. Maidul Islam
Md. Maidul Islam

Reputation: 574

After proxy setting ( What is the proxy IP in your organization), I have added following code in build.gradle file. The problem has gone.

sourceSets {
main {
    output.setResourcesDir(java.outputDir)
   }
}

Upvotes: 0

Leena Varshney
Leena Varshney

Reputation: 21

Below code works for me:-

buildscript {
ext { springBootVersion = '2.0.5.RELEASE'}
repositories { mavenCentral() }
dependencies {
    classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}}

apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

group 'com.example'
version '1.0-SNAPSHOT'

repositories {
mavenCentral()
}


dependencies {
implementation group: 'org.springframework.boot', name: 'spring-boot- 
starter-web', version: '2.0.5.RELEASE'
}

Upvotes: 0

Geetha
Geetha

Reputation: 19

Got a similar exception

Caused by: org.gradle.internal.resolve.ArtifactNotFoundException: Could not find spring-boot-gradle-plugin-3.0.0-SNAPSHOT.jar (org.springframework.boot:spring-boot-gradle-plugin:3.0.0-SNAPSHOT:20220216.230329-214)

Running the gradle build with --refresh-dependencies fixed it

Upvotes: 0

Capfer
Capfer

Reputation: 901

As of now July first 2020, this is how I was able to configure it, and it worked! Hopefully, this can help anyone facing this problem. Note: Pay attention to the versions

buildscript {
        repositories {
            mavenCentral()
        }
        dependencies {
            classpath('org.springframework.boot:spring-boot-gradle-plugin:2.2.8.RELEASE')
        }
    }
    
    plugins {
        id 'org.springframework.boot' version '2.2.8.RELEASE'
        id 'java'
    }
    
    group 'org.capfer'
    version '1.0-SNAPSHOT'
    
    sourceCompatibility = 1.8
    
    repositories {
        mavenCentral()
    }
    
    dependencies {
        testCompile group: 'junit', name: 'junit', version: '4.12'
        compile('org.springframework.boot:spring-boot-starter-web:2.2.8.RELEASE')
    }

Upvotes: -1

Ahmed
Ahmed

Reputation: 69

Check your syntax and where your parentheses close } I had the same issue and it turned out my repositories { didnt contain } at the end

Upvotes: 0

Mark Vieira
Mark Vieira

Reputation: 13476

Applying a plugin by plugin id is not supported in script plugins. You must use the plugin's fully qualified class name.

apply plugin: org.springframework.boot.gradle.plugin.SpringBootPlugin

See this thread for more information.

UPDATE: Updating plugin class name.

Upvotes: 27

Elkin Hurtado
Elkin Hurtado

Reputation: 176

  1. Add:

    buildscript {
        repositories {
            maven {
                url "https://plugins.gradle.org/m2/"
            }
        }
        dependencies {
            classpath "org.springframework.boot:spring-boot-gradle-plugin:2.0.4.RELEASE"
        }}
    
  2. Change:

    apply plugin: 'spring-boot'
    

    to:

    apply plugin: "org.springframework.boot"
    

Upvotes: 7

raju joshi
raju joshi

Reputation: 81

This code works for me

 plugins{

  id 'org.springframework.boot' version '2.0.3.RELEASE'

 }

Upvotes: 8

Fabrizio Fortino
Fabrizio Fortino

Reputation: 1616

Starting from SpringBoot 1.4.0.RELEASE the plugin package has been slightly changed.

apply plugin: org.springframework.boot.gradle.plugin.SpringBootPlugin

Upvotes: 1

Dirk Hoffmann
Dirk Hoffmann

Reputation: 19

could it be, that you don't have a @SpringBootApplication with a main(String[] main) on your classpath ??

Upvotes: -6

Related Questions