元素“值”;不能包含子元素“object”因为父元素的内容模型只是文本

发布于 2024-11-09 07:06:28 字数 1488 浏览 5 评论 0原文

我有一个 IDictionary 类型的属性,其键类型和值类型不是字符串。互联网和 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”,因为父元素的内容模型仅为文本。

我的配置有问题吗?

I have a property of IDictionary type with key type and value type other than string. Most of the examples given on the internet and in Spring.Net uses string as one of the types.

Here are the config settings:

<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>

I am getting the following ConfigurationErrorException:

Error creating context 'spring.root': The element 'http://www.springframework.net:value' cannot contain child element 'http://www.springframework.net:object' because the parent element's content model is text only.

Is there something wrong in my config?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

£冰雨忧蓝° 2024-11-16 07:06:28

我不确定字典配置是否支持 内联键和/或值的对象定义有关设置集合值的文档中没有提到它< /a>.

你能尝试一下这个配置吗:

<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>

I'm not sure if the dictionary configuration supports inline object definitions for keys and/or values. It's not mentioned in the documentation on setting collection values.

Could you try this configuration:

<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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文