Gradle Spring Boot plugin: "Unable to load class"


(merlijn) #1

Hi, I want to set up a Spring Boot project using a local jar of the Spring Boot Gradle plugin. I am following the official guide.

The only difference I have in my build script is the following line:

`classpath files("libs/spring-boot-gradle-plugin-1.4.2.RELEASE.jar")`

I get the following error:

Unable to load class 'org.springframework.boot.loader.tools.Layout'

Does anyone know if the syntax for including the jar is correct, and if not: what the correct syntax is. I have also tried using

compile files('libs/spring-boot-gradle-plugin-1.4.2.RELEASE.jar')

but then the plugin cannot be found. Another thing I have tried is adding my libs folder as a repository and then using the standard string notation in the classpath:

flatDir { dir 'libs' } dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.2.RELEASE") }

But then I get a NotSerializableException in org.gradle.internal.component.local.model.DefaultProjectComponentIdentifier

Any help would be greatly appreciated.


(Alexander Volanis) #2

Plugin classpath is configured in the buildscript closure of your build.gradle.

buildscript {
    repositories {
        flatDir {
            dir 'libs'
        }
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.2.RELEASE")
    }
}