1

I am getting above exception when i try to run simple spring example

Following line of code try to read spring beans from beans1.xml

ApplicationContext context = new ClassPathXmlApplicationContext("beans1.xml");

Following is the complete exception i am getting.

Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [beans1.xml]; nested exception is java.io.FileNotFoundException: class path resource [beans1.xml] cannot be opened because it does not exist

I have put xml file in every possible location hoping that program will detect the file. But still this program can not find this bean configuration file. Also i am using maven as the build tool, but i am running the program using Eclipse IDE

2 Answers 2

6

put it in resources directory of maven project

src/main/resources/beans1.xml
Sign up to request clarification or add additional context in comments.

Comments

0

check the name,your bean.xml file name should be same as what you have mentioned here ie., beans.xml ClassPathXmlApplicationContext("beans1.xml"):

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.