如何解决元素“值”不能包含子元素“对象”,因为父元素的内容模型仅是文本
| 我有一个IDictionary
类型的属性,除了字符串以外,还具有键类型和值类型。 Internet和Spring.Net中给出的大多数示例都使用字符串作为类型之一。
这是配置设置:
<property name=\"DirectoryServiceAgents\">
<dictionary key-type=\"OM.ServiceTier.DTO.Transients.AuthenticationDomainIdentifier,OM.ServiceTier\" value-type=\"OM.ServiceTier.Services.User.Internal.IDirectoryServiceAgent,OM.ServiceTier\">
<entry>
<key>
<object type=\"OM.ServiceTier.DTO.Transients.AuthenticationDomainIdentifier,OM.ServiceTier\">
<constructor-arg type=\"string\" value=\"${activeDirectory.Domain}\"/>
</object>
</key>
<value>
<object type=\"OM.ServiceTier.Services.User.Internal.DirectoryServiceAgent,OM.ServiceTier\">
<property name=\"LDAPPath\" value=\"${activeDirectory.LDAPPath}\"/>
<property name=\"LDAPContainer\" value=\"${activeDirectory.LDAPContainer}\"/>
<property name=\"UserName\" value=\"${activeDirectory.UserName}\"/>
<property name=\"Password\" value=\"${activeDirectory.Password}\"/>
</object>
</value>
</entry>
</dictionary>
</property>
我得到以下ConfigurationErrorException
:
创建上下文\'spring.root \'时出错:元素\'http://www.springframework.net:value \'不能包含子元素\'http://www.springframework.net:object \',因为父元素元素的内容模型仅是文本。
我的配置有问题吗?
解决方法
我不确定字典配置是否支持键和/或值的内联对象定义。有关设置集合值的文档中未提及。
您可以尝试以下配置:
<object>
<!-- snip -->
<property name=\"DirectoryServiceAgents\">
<dictionary
key-type=\"OM.ServiceTier.DTO.Transients.AuthenticationDomainIdentifier,OM.ServiceTier\"
value-type=\"OM.ServiceTier.Services.User.Internal.IDirectoryServiceAgent,OM.ServiceTier\">
<entry key-ref=\"authDomainId\" value-ref=\"serviceAgent\"/>
</dictionary>
</property>
<!-- snip -->
</object>
<object id=\"authDomainId\"
type=\"OM.ServiceTier.DTO.Transients.AuthenticationDomainIdentifier,OM.ServiceTier\">
<constructor-arg type=\"string\" value=\"${activeDirectory.Domain}\"/>
</object>
<object id=\"serviceAgent\"
type=\"OM.ServiceTier.Services.User.Internal.DirectoryServiceAgent,OM.ServiceTier\">
<property name=\"LDAPPath\" value=\"${activeDirectory.LDAPPath}\"/>
<property name=\"LDAPContainer\" value=\"${activeDirectory.LDAPContainer}\"/>
<property name=\"UserName\" value=\"${activeDirectory.UserName}\"/>
<property name=\"Password\" value=\"${activeDirectory.Password}\"/>
</object>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。