use*_*206 3 java spring dictionary dependency-injection
我试图在我的 Spring beans xml 中定义一个枚举映射,我希望它填充在 xml 中,但是当我尝试像这样定义它时
<bean class = "java.util.EnumMap">
    <constructor-arg>
        <util:map key-type="org.itemlist.products.stockitem">
            <entry key="stockitem.SOAP">100</entry>
        </util:map> 
    </constructor-arg>
更新
这是我的 bean 配置
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:util="http://www.springframework.org/schema/util"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-3.0.xsd
    http://www.springframework.org/schema/util 
    http://www.springframework.org/schema/util/spring-util-3.0.xsd">
    <bean class = "java.util.EnumMap">
        <constructor-arg>
            <util:map key-type="org.itemlist.products.stockitem">
                <entry key="stockitem.SOAP">100</entry>
            </util:map> 
        </constructor-arg>
    </bean>
</beans>
当我在条目中添加一个值时,现在是错误
cvc-complex-type.2.3: Element 'entry' cannot have character [children], because the type's content type is element-only.
您是否在标题中定义了这些架构:
http://www.springframework.org/schema/util 
http://www.springframework.org/schema/util/spring-util-3.0.xsd
和命名空间:
xmlns:util="http://www.springframework.org/schema/util"
| 归档时间: | 
 | 
| 查看次数: | 4493 次 | 
| 最近记录: |