Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Both <code>map</code> and <code>list</code> has this attribute named <code>merge=true|false</code> for merging two lists. Alternatively you can use <code>MethodInvokingFactoryBean</code> for calling already defined list's add method to add extra items later.</p> <p>Let's go over your example. </p> <p>1) First the second scenario with <code>MethodInvokingFactoryBean</code>. Instead of defining the way you do, I defined your beans a little differently.</p> <pre><code>&lt;bean class="java.util.HashMap" id="exampleMapping"&gt; &lt;constructor-arg index="0"&gt; &lt;map&gt; &lt;entry key="theKey" value="theValue"/&gt; &lt;/map&gt; &lt;/constructor-arg&gt; &lt;/bean&gt; &lt;bean id="exampleService" class="com.stackoverflow.example.ExampleService"&gt; &lt;property name="mapping" ref="exampleMapping"/&gt; &lt;/bean&gt; </code></pre> <p>In another application content file, you can do the following to extend the map.</p> <pre><code>&lt;bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"&gt; &lt;property name="targetObject" ref="exampleMapping"/&gt; &lt;property name="targetMethod" value="putAll"/&gt; &lt;property name="arguments"&gt; &lt;list&gt; &lt;map id="exampleMapping"&gt; &lt;entry key="theKey2" value="theValue2"/&gt; &lt;entry key="theKey3" value="theValue3"/&gt; &lt;map&gt; &lt;/list&gt; &lt;/property&gt; &lt;/bean&gt; </code></pre> <p>2) Now the first scenario. For this one, I just found something on page <a href="http://forum.springsource.org/showthread.php?t=53358" rel="noreferrer">http://forum.springsource.org/showthread.php?t=53358</a></p> <pre><code>&lt;bean id="commonData" class="A"&gt; &lt;property name="map"&gt; &lt;util:map&gt; &lt;entry key="1" value="1"/&gt; &lt;/util:map&gt; &lt;/property&gt; &lt;/bean&gt; &lt;bean id="data" class="A" parent="commonData"&gt; &lt;property name="map"&gt; &lt;util:map merge="true"&gt; &lt;entry key="2" value="2"/&gt; &lt;/util:map&gt; &lt;/property&gt; &lt;/bean&gt; </code></pre> <p>Hope it helps.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload