1

I have testBeanId which refers testList

 <bean id="testBeanId" class="com.test">
       <property name="testList" ref="testList"/>
   </bean>

Now testList is defined under two different xml files which can be under same/separate jar files

XML1

  <util:list id="testList">
       <value>1</value>
       <value>2</value>
   </util:list>

XML2

<util:list id="testList">
       <value>3</value>
   </util:list>

My question is which list will be injected under testBeanId. Will it be 3 or 1,2 ?

As per my understanding from skaffman answer at Spring's overriding bean , we can have two bean with same id provided its in two different xml files but will never be sure which one will be injected. Hence error prone

But lboix answer says bean from second file will override first one. But i am not sure which one will be second file as its dependent on classloaded is n't it ?

Community
  • 1
  • 1
emilly
  • 10,060
  • 33
  • 97
  • 172
  • What do you mean by classloaded? do you mean classloader? well, actually it depends on your `context.xml` file. in your application context xml file, you can configure this by looking at the sequence of your import tag. – kucing_terbang May 09 '15 at 12:24

0 Answers0