Spring's overriding bean

后端 未结 8 1468
忘了有多久
忘了有多久 2020-12-01 03:02

Can we have duplicate names for the same bean id that is mentioned in the XML? If not, then how do we override the bean in Spring?

8条回答
  •  独厮守ぢ
    2020-12-01 03:36

    I will add that if your need is just to override a property used by your bean, the id approach works too like skaffman explained :

    In your first called XML configuration file :

       
           
       
    
       
           3
           4
       
    

    In your second called XML configuration file :

       
           6
       
    

    Then your bean "myBeanId" will be instantiated with a "myList" property of one element which is 6.

提交回复
热议问题