How to extend already defined lists and maps in Spring application context?

后端 未结 2 1020
轻奢々
轻奢々 2021-02-02 14:45

Imagine a staged application context with different phases. We start with an early phase to define the necessary infrastructure. The xml application contexts are loaded sequenti

2条回答
  •  悲&欢浪女
    2021-02-02 15:36

    Both map and list has this attribute named merge=true|false for merging two lists. Alternatively you can use MethodInvokingFactoryBean for calling already defined list's add method to add extra items later.

    Let's go over your example.

    1) First the second scenario with MethodInvokingFactoryBean. Instead of defining the way you do, I defined your beans a little differently.

    
        
            
                
            
        
    
    
    
        
    
    

    In another application content file, you can do the following to extend the map.

    
        
        
        
            
                
                
                
                
            
        
    
    

    2) Now the first scenario. For this one, I just found something on page http://forum.springsource.org/showthread.php?t=53358

    
        
            
                
            
        
    
    
        
            
                
            
        
    
    

    Hope it helps.

提交回复
热议问题