0

I am trying to make a Spring Helloworld application, but I get the following exception:

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'helloWorld' defined in class path resource [spring.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/springframework/core/io/support/SpringFactoriesLoader
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:529)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:626)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:469)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at com.sdnext.dineshonjava.tutorial.SpringJavaApp.main(SpringJavaApp.java:11)

Here are my Maven dependencies : maven dependencies

The SpringFactoriesLoader class is obviously missing from the package, so what should I do? I tried to change the version of the spring-core dependency to 3.2.2, but I get an error in the pom.xml saying Missing artifact org.springframework:spring-core:jar:3.2.2

In my spring.xml configuration file I have declared the following bean :

 <bean class="com.sdnext.dineshonjava.tutorial.HelloWorld" id="helloWorld">
   <property name="message" value="Hello World!">

I also have the class HelloWorld in that package.

I am thinking that maybe there is a version conflict somewhere, but how can I figure out where is the problem?

  • 1
    You have conflicting version of Spring. [`SpringFactoriesLoader`](http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/core/io/support/SpringFactoriesLoader.html) was introduced in 3.2 and some other dependency must be pulling an older version of Spring. The version should be `3.2.2.RELEASE`. You have to make sure you use a single version, not multiple ones. – Tunaki Oct 15 '16 at 17:03
  • @Tunaki thanks, this worked! – Elena Alexandra Dobrescu Oct 15 '16 at 17:12

0 Answers0