Announcement Announcement Module
Collapse
No announcement yet.
Merging maps in xml file for parent-child beans Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Merging maps in xml file for parent-child beans

    G'day!

    I'm trying to merge my maps in Spring. However, I'm coming across a problem with it.

    So, here's the code (and yes, I'm using Spring 2.0):

    Code:
    <bean id="parent-bean" abstract="true">
    		<property name="mapValues">
    	      	<map>
    	      		<entry key="key">
    	      			<value>value</value>
    	      		</entry>
    	      	</map>
          </property>
    </bean>
    
    <bean id="child-bean" parent="parent-bean" class="some.class.here">
    		<property name="mapValues">
    	      	<map merge="true">
    	      		<entry key="key2">
    	      			<value>value2</value>
    	      		</entry>
    	      	</map>
          </property>
    </bean>
    Now, the problem is that at startup, I get this error:

    Code:
    org.springframework.beans.factory.BeanDefinitionStoreException: Line XXX in XML document from ServletContext
    resource [/WEB-INF/spring-config/config-name.xml] is invalid; nested exception is org.xml.sax.SAXParseException: Attribute "merge" must be declared for element type "map".
    Caused by:
    org.xml.sax.SAXParseException: Attribute "merge" must be declared for element type "map".
    Where, Line XXX is listed every time I have a merge=true definition. I can't see the problem - can anyone else?

    Thanks,
    Andrew

  • #2
    That's probably an issue of the doctype declaration in your file. You probably still reference the spring-beans.dtd instead of the spring-beans-2.0.dtd.

    Jörg

    Comment


    • #3
      If you are going to change this, it might be worth going for it and using XML schema instead.
      http://www.springframework.org/docs/...-configuration
      Last edited by karldmoore; Aug 27th, 2007, 03:32 PM.

      Comment

      Working...
      X