Reputation: 41
In my class I have this setter
public void setSomehing(Map<Object, Class<?>> beans){
...
}
Object
is some bean, and Class
is it's interface.
I try more combination but I always got
cvc-complex-type.2.3:
Element 'map' cannot have character [children], because the type's content type is element-only.
Some of combination is:
<bean id="rmiServerBeanFactory" class="org.infobip.spring.remoting.server.StandaloneCompositeRmiServerBeanFactory">
<property name="something">
<map>
<entry key-ref="myBean" value="org.mypackage.MyBeanInterface"/>
</map>
</property>
</bean>
Please help. how to set this in spring.xml?
Upvotes: 4
Views: 6222
Reputation: 3394
Your XML formatting and syntax is wrong somewhere. What it really means (the Sinn) is that the ... element is allowed to contain sub-elements, but not naked text ("content type is element-only") and the stray plus sign is naked text.
Upvotes: 0
Reputation: 529
There's a few ways of doing this, but one of the more compact ones is as follows:
<map value-type="java.lang.Class">
<entry key-ref="myBean"
value="org.mypackage.MyBeanInterface"/>
</map>
(Tested on Spring 3.0.)
Upvotes: 0
Reputation: 16525
hm maybe this example in my application helps you:
namespace util is
xmlns:util="http://www.springframework.org/schema/util"
<property name="something">
<util:map map-class="java.util.concurrent.ConcurrentHashMap">
<entry key="a" value="b"/>
</util:map>
</property>
Upvotes: 0
Reputation: 8875
This error message is due to a syntax error in the XML. In this example, you only want the map element to have a single entry child right? Look for stray characters between the opening and closing map tags. Try retyping all then content of that element again as you intended it.
See a similar problem and solution here. You only need to look at the first and last post.
Upvotes: 1