我想在其他一些设置文件中配置spring.net,比如xml,而不是通过app.config。有没有可能用xml而不是app.config file.if来配置spring.net是的,我该怎么做?
发布于 2011-07-11 19:46:36
可以,您可以将您的配置放在普通的xml文件中。在Spring.NET文档中,the following example is given
services.xml
<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具有类似的结构,并包含ItemDao和AccountDao的定义。
在代码中,您可以使用文件services.xml和daos.xml创建容器的实例,如下所示:
IApplicationContext context = new XmlApplicationContext("services.xml", "daos.xml")https://stackoverflow.com/questions/6647909
复制相似问题