Spring 3 @ImportResource with multiple files

别说谁变了你拦得住时间么 提交于 2019-11-28 06:22:31

Try:

@Configuration  
@ImportResource( { "spring-context1.xml", "spring-context2.xml" } )  
public class ConfigClass { }  

You need to add the classpath before the file name

@ImportResource(value = { 
    "classpath:file1.xml",
    "classpath:file2.xml"
    })
Sameer Patil

Just adding for future reference if anyone is using this in a groovy project.

In groovy the correct syntax uses [ ] square brackets . The curly braces will lead to compilation errors. Please find the example below.

@Configuration  
@ImportResource( [ "spring-context1.xml", "spring-context2.xml" ] ) 
joanluk

The correct format to define multiple spring resources spring xml context files using Spring 3 @ImportResource:

@Configuration  
@ImportResource( { "spring-context1.xml", "spring-context2.xml" } ) 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!