KItis
KItis

Reputation: 5646

IOException parsing XML document from class path resource [beans1.xml]; nested exception is java.io.FileNotFoundException

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

Upvotes: 1

Views: 14150

Answers (2)

user2497599
user2497599

Reputation: 19

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

Upvotes: 0

Jigar Joshi
Jigar Joshi

Reputation: 240900

put it in resources directory of maven project

src/main/resources/beans1.xml

Upvotes: 6

Related Questions