Reputation: 837
I am new to Spring, i am trying to understand the statement "ClassPathXMLApplication context searches for xml in all jars in classpath".
So in an application
ApplicationContext context = new ClassPathXmlApplicationContext("myBeans.xml");
will it search in all the dependent jars for this myBeans.xml?
Upvotes: 1
Views: 696
Reputation: 1289
Here is the link to understand how to pass the application bean context using constructors.
ApplicationContext context = new ClassPathXmlApplicationContext("myBeans.xml");
works fine if placed under src/resources/myBeans.xml , because
The classpath root is WEB-INF/classes, and src/main/resources goes there, together with src/main/java
Upvotes: 0
Reputation: 356
It will work , but you are not giving path of file right , since it is in a jar in classpath , you have to give something like this
ApplicationContext context = new ClassPathXmlApplicationContext("classpath*:**/myBeans.xml");
Hope this will help.
Upvotes: 1