I started to learn Spring Framework as my first ever app.I tried to get defined Beans count but i can't run it.
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
public class runDemo {
public static void main(String[] args) {
ApplicationContext context = new AnnotationConfigApplicationContext();
System.out.println(context.getBeanDefinitionCount());
}
}
and my gradle file
buildscript {
ext {
springBootVersion = '1.5.6.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')
}
and when i run this:
Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContext
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:123)
Caused by: java.lang.ClassNotFoundException: org.springframework.context.ApplicationContext ...
I have spring context and spring core in the External Libraries loaded.
EDIT:I upgraded to Intellij idea 2017.2 and it still give the same error