元素“值”不能包含子元素“对象”,因为父元素的内容模型仅是文本

| 我有一个
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>
    

要回复问题请先登录注册