首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Spring.net上下文层次结构不起作用

Spring.net上下文层次结构不起作用
EN

Stack Overflow用户
提问于 2013-11-08 19:48:51
回答 1查看 924关注 0票数 1

Spring版本: 2.0.0.40000运行时:.NET 4.5

以此处显示的示例www.springframework.net/.../objects.htmlhttp://springframework.net/docs/1.3..../webframe.html - ContextHandler接口为例

我有以下几点

代码:

代码语言:javascript
复制
<configSections>
  <sectionGroup name="spring">
    <section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core"/>
    <section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core" />
    <sectionGroup name="child">
    <section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core"/>
    </sectionGroup> 
  </sectionGroup> 
</configSections>

<spring>
  <objects xmlns="http://www.springframework.net">
    <import resource="assembly://ProjectDLL/Config/Spring.xml"/> 
  </objects>

  <child>
    <objects xmlns="http://www.springframework.net">
      <object name="eventLog"
          type="System.Diagnostics.EventLog, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
          >
        <constructor-arg type="string" name="logName" value="v1"  />
        <constructor-arg type="string" name="machineName" value="."  />
        <constructor-arg type="string" name="source" value="v1"  />
      </object>
    </objects>
  </child>  

  <context name="Parent">
    <resource uri="config://spring/objects"/>
    <context name="child">
    <resource uri="config://spring/child/objects"/>
    </context>
  </context>
</spring>

呼叫

代码语言:javascript
复制
ContextRegistry.GetContext();

任何上下文名称的结果都是

消息-创建上下文‘ChildContext’时出错:后处理对象工厂时出错。

我尝试了所有不同的命名,包括孩子,ChildContext,孩子,都导致了相同的错误。

在我的示例中,我使用了一个包含我的对象的资源文件( ),如果我不导入我自己的XML文件,它可以工作,但导入它意味着孩子不能工作。如果我在同一个xml文件中定义子元素,我会得到“创建上下文‘Parent’时出错:有多个根元素”

我知道这很可能是配置问题,如果有任何帮助,我将不胜感激。

EN

回答 1

Stack Overflow用户

发布于 2013-11-14 17:18:46

由于不完全理解我得到的错误或原因,解决方法是使用“依赖”来启动。spring xsd在这里定义了一些安静的http://www.springframework.net/xsd/spring-objects.xsd

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19858418

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档