A B
A B

Reputation: 105

Failed to apply plugin [id 'spring-boot']

I am trying to use Spring boot in my gradle project. But when I try to clean build, it gives the following error (only relevant stacktrace):

Caused by: org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin [id 'spring-boot']
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyPlugin(DefaultObjectConfigurationAction.java:117)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.access$200(DefaultObjectConfigurationAction.java:36)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction$3.run(DefaultObjectConfigurationAction.java:80)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.execute(DefaultObjectConfigurationAction.java:131)
at org.gradle.api.internal.project.AbstractPluginAware.apply(AbstractPluginAware.java:37)
at org.gradle.api.Project$apply.call(Unknown Source)
at org.gradle.api.internal.project.ProjectScript.apply(ProjectScript.groovy:34)
at org.gradle.api.Script$apply.callCurrent(Unknown Source)
at build_2o7juvjo3110jmss6k1iqcfrir.run(/Users/AlmasBarday/bos-api/build.gradle:13)
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:52)
... 57 more
Caused by: org.gradle.api.plugins.UnknownPluginException: Plugin with id 'spring-boot' not found.
at org.gradle.api.internal.plugins.DefaultPluginRegistry.getTypeForId(DefaultPluginRegistry.java:91)
at org.gradle.api.internal.plugins.DefaultPluginContainer.getTypeForId(DefaultPluginContainer.java:183)
at org.gradle.api.internal.plugins.DefaultPluginContainer.apply(DefaultPluginContainer.java:103)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyPlugin(DefaultObjectConfigurationAction.java:115)

My build.gradle has the following:

apply plugin: 'java'
apply plugin: 'maven-publish'
apply plugin: 'spring-boot'

dependencies {
 compile 'org.slf4j:slf4j-api:1.7.5'
 compile 'net.sourceforge.jexcelapi:jxl:2.6.12'
 compile 'com.qas:proweb:1.0.0'

compile "org.springframework:spring-beans:$springVersion"
compile "org.springframework:spring-jdbc:$springVersion"
compile "org.springframework:spring-web:$springVersion"

compile "org.springframework.boot:spring-boot-starter-web:1.2.7.RELEASE"

testCompile 'junit:junit:4.11'
}

I searched the internet and tried solutions posted to similar problems, but nothing seems to work. Also, I am able to build another gradle-springboot project without any problems.

Any help appreciated.

Upvotes: 4

Views: 24488

Answers (2)

jian
jian

Reputation: 21

plugins { id "org.springframework.boot" version "2.0.1.RELEASE" }

The above script should also be added to build.gradle at the top level to make it work.

Upvotes: 0

Stanislav
Stanislav

Reputation: 28096

You've forgot to configure you buildscript, by adding it's dependencies part. You can do it, by addin this to your build.script:

buildscript {

    repositories {
        mavenCentral()
        jcenter()
    }

    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.5.RELEASE")
    }
}

Here you're configuring your buildscript dependencies, to make it possible for Gradle to apply the plugin. But that does not mean, that you can delete dependency for you sources. They are still use to be there, like you already have:

dependencies {
    ...
    compile "org.springframework:spring-beans:$springVersion"
    compile "org.springframework:spring-jdbc:$springVersion"
    compile "org.springframework:spring-web:$springVersion"

    compile "org.springframework.boot:spring-boot-starter-web:1.2.7.RELEASE"
}

Upvotes: 4

Related Questions