0
app.configではなくxmlのようないくつかの設定ファイルでspring.netを設定したいと思います。 app.configファイルではなく、xmlのspring.netを設定することは可能ですか?どうすればいいですか?App.configなしのSpring.Net
app.configではなくxmlのようないくつかの設定ファイルでspring.netを設定したいと思います。 app.configファイルではなく、xmlのspring.netを設定することは可能ですか?どうすればいいですか?App.configなしのSpring.Net
はい、通常の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>
類似した構造を有しており、ItemDao
とAccountDao
の定義が含まdaos.xml
ファイル。
コードでは、次のようにファイルservices.xml
とdaos.xml
を使用して、コンテナのインスタンスを作成することができます。
IApplicationContext context = new XmlApplicationContext("services.xml", "daos.xml")