I don't know,how to load multiple configuration files from classpath in spring using @ImportResource.I have already gone through the link Spring 3 @ImportResource with multiple files but no luck so far. My code is below.
@Configuration
@PropertySource("classpath:apis.application.properties")
@ComponentScan(basePackages = {"org.surfnet.oaaas.resource", "org.surfnet.oaaas.service"})
@ImportResource({"classpath:spring-repositories.xml,classpath:commonApplicationContext.xml"})
@EnableTransactionManagement
public class SpringConfiguration {
}
Exception i am facing is
java.io.FileNotFoundException: class path resource [spring-repositories.xml,classpath:commonApplicationContext.xml] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:157)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:328)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
How ever when i try to load a single file,like below.it works for both file.But i can not include two ImportResource
annotation in a java class.
@ImportResource("classpath:spring-repositories.xml"})
You are using the wrong syntax. Look carefully at how it's done in the question you linked to.
There are two strings, not one string containing names separated by commas:
@ImportResource({"classpath:spring-repositories.xml", "classpath:commonApplicationContext.xml"})
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments