首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >不带App.config的Spring.Net

不带App.config的Spring.Net
EN

Stack Overflow用户
提问于 2011-07-11 17:06:06
回答 1查看 715关注 0票数 0

我想在其他一些设置文件中配置spring.net,比如xml,而不是通过app.config。有没有可能用xml而不是app.config file.if来配置spring.net是的,我该怎么做?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-07-11 19:46:36

可以,您可以将您的配置放在普通的xml文件中。在Spring.NET文档中,the following example is given

services.xml

代码语言:javascript
复制
<objects xmlns="http://www.springframework.net"> 

  <object id="PetStore" type="PetStore.Services.PetStoreService, PetStore">
    <property name="AccountDao" ref="AccountDao"/>
    <property name="ItemDao" ref="ItemDao"/>
    <!-- additional collaborators and configuration for this object go here -->
  </object>

  <!-- more object definitions for services go here -->

</objects>

文件daos.xml具有类似的结构,并包含ItemDaoAccountDao的定义。

在代码中,您可以使用文件services.xmldaos.xml创建容器的实例,如下所示:

代码语言:javascript
复制
IApplicationContext context = new XmlApplicationContext("services.xml", "daos.xml")
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6647909

复制
相关文章

相似问题

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