2

I am attempting to develop a Spring boot project using inteliJ

I have build a starter project using Spring boot INITIALIZR using spring 1.5.2, gradle build and no extra modules.

I have imported this into inteliJ as a gradle project.

I am able to run the test (from intelij) which comes what a starter project I am able to build and run the project on the command line

but it will not run the main project from intelij

When i try to run the project i get the following error


Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/boot/SpringApplication
    at com.bfc.BfcApplication.main(BfcApplication.java:10)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.SpringApplication
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 6 more

In the past i have had no problem with spring boot projects.

The only difference between this project and my last one is that my last one used spring boot 1.4.3

I have tried creating a new spring initilizer project with version 1.4.3, gradle and all other settings set to default and this solved the issue. Only 1.5.2 has a problem

my gradle.build file is as follows


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

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'

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')
}

megaman
  • 1,035
  • 1
  • 14
  • 21

0 Answers0