Reputation: 113
I have a java application that use spring with a spring.xml file in the web content. I have in my java class this piece of code:
ApplicationContext context = new ClassPathXmlApplicationContext("WEB-INF/spring-conf.xml");
WService ws = (WService) context.getBean("service");
In that spring.xml I import a xml file that lives in a library (bundle) that I've put in my project as an external library.
<import resource="classpath:/org/bundle/spring2.xml" />
and it works but in spring2.xml and in the bundle there are also:
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>../properties/environment.properties</value>
</property>
</bean>
<import resource="../commons/datasources.xml"></import>
<import resource="../commons/context-resources.xml"></import>
and I can't find these xml files because they live in the bundle, not in my webcontent. How can I indicate in my spring-conf.xml the positions of the other xml files from the beginning? If there are another method to do this you're welcome. Thank you very much.
Upvotes: 0
Views: 3621
Reputation: 12880
Did you try to edit these imports to use classpath prefix?
<import resource="classpath:/org/commons/datasources.xml"/>
<import resource="classpath:/org/commons/context-resources.xml"/>
This way they should be available to anyone using this library.
Upvotes: 1
Reputation: 21564
Try importing yourself the XMLs in your spring-conf.xml
:
<import resource="classpath:<PACKAGE_PATH>/datasources.xml" />
<import resource="classpath:<PACKAGE_PATH>/context-resources.xml" />
and replace PACKAGE_PATH
with the correct value :-)
Upvotes: 1