特定のアプリケーションのための複数のプロファイル:
その他のリレーショナル設定ファイル:
- 並置されました
- 含みます
パラレルな関係
同時に複数のコンフィギュレーション・ファイルをロードする必要が複数の設定ファイルがあること。
可変パラメータを使用することができ、ワイルドカードのアレイをロード。
- 可変パラメータ
String config1 = "com/abc/di08/spring-student.xml";
String config2 = "com/abc/di08/spring-school.xml";
//加载配置文件,生成spring容器对象(多个字符串参数加载多个配置文件)
ApplicationContext ac = new ClassPathXmlApplicationContext(config1,config2);
- ロードアレイ
String config1 = "com/abc/di08/spring-student.xml";
String config2 = "com/abc/di08/spring-school.xml";
String[] configs = {config1,config2};
//加载配置文件,生成spring容器对象(数组加载多个配置文件)
ApplicationContext ac = new ClassPathXmlApplicationContext(configs);
- ワイルドカード負荷
String config = "com/abc/di08/spring-*.xml";
//加载配置文件,生成spring容器对象(通配符加载多个配置文件)
ApplicationContext ac = new ClassPathXmlApplicationContext(config);
包含関係
まず、メインの設定ファイル内の別のプロファイルをロードし、ワイルドカード使用して、マスターの設定ファイルをロードし、そして。
String config = "com/abc/di09/applicationContext.xml";
ApplicationContext ac = new ClassPathXmlApplicationContext(config);
<!--import标签加载包含配置文件-->
<import resource="spring-*.xml"/>