2011-07-11 11 views
0

app.configではなくxmlのようないくつかの設定ファイルでspring.netを設定したいと思います。 app.configファイルではなく、xmlのspring.netを設定することは可能ですか?どうすればいいですか?App.configなしのSpring.Net

答えて

3

はい、通常の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> 

類似した構造を有しており、ItemDaoAccountDaoの定義が含まdaos.xmlファイル。

コードでは、次のようにファイルservices.xmldaos.xmlを使用して、コンテナのインスタンスを作成することができます。

IApplicationContext context = new XmlApplicationContext("services.xml", "daos.xml")