Spring 3 @ImportResource with multiple files

前端 未结 4 1775
抹茶落季
抹茶落季 2020-12-08 15:17

I\'m trying to find the syntax for importing multiple spring xml context files using Spring 3 @ImportResource annotation.

I have tried using comma to separate the fi

相关标签:
4条回答
  • 2020-12-08 15:28

    Try:

    @Configuration  
    @ImportResource( { "spring-context1.xml", "spring-context2.xml" } )  
    public class ConfigClass { }  
    
    0 讨论(0)
  • 2020-12-08 15:29

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

    @Configuration  
    @ImportResource( { "spring-context1.xml", "spring-context2.xml" } ) 
    
    0 讨论(0)
  • 2020-12-08 15:39

    You need to add the classpath before the file name

    @ImportResource(value = { 
        "classpath:file1.xml",
        "classpath:file2.xml"
        })
    
    0 讨论(0)
  • 2020-12-08 15:41

    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" ] ) 
    
    0 讨论(0)
提交回复
热议问题