Spring中加载多个Properties配置文件
2015-03-20 11:05
435 查看
单个配置:
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>classpath:jdbc.properties</value>
</property>
</bean>
多个配置:
<!-- 将多个配置文件读取到容器中,交给Spring管理 -->
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<!-- 这里支持多种寻址方式:classpath和file -->
<value>classpath:/opt/demo/config/demo-db.properties</value>
<!-- 推荐使用file的方式引入,这样可以将配置和代码分离 -->
<value>file:/opt/demo/config/demo-mq.properties</value>
<value>file:/opt/demo/config/demo-remote.properties</value>
</list>
</property>
</bean>
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>classpath:jdbc.properties</value>
</property>
</bean>
多个配置:
<!-- 将多个配置文件读取到容器中,交给Spring管理 -->
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<!-- 这里支持多种寻址方式:classpath和file -->
<value>classpath:/opt/demo/config/demo-db.properties</value>
<!-- 推荐使用file的方式引入,这样可以将配置和代码分离 -->
<value>file:/opt/demo/config/demo-mq.properties</value>
<value>file:/opt/demo/config/demo-remote.properties</value>
</list>
</property>
</bean>
相关文章推荐
- [Spring boot]配置文件properties加载
- spring 加载配置文件application.properties,类里如何调用@Value的解决办法
- 在spring配置文件中引入properties文件--引出加载配置文件的对应方式
- 详解利用Spring加载Properties配置文件
- 可以从Jar外部加载JDBC.properties的Spring-mybatis配置文件
- Spring配置文件加载properties文件
- 解决eclipse创建spring boot项目加载不到application.properties配置文件的问题
- IDEA spring的xml配置文件加载不到properties属性问题
- IDEA spring的xml配置文件加载不到properties属性问题
- spring加载一个或者多个properties配置文件方法
- Spring加载Properties配置文件的加密解密处理
- spring加载properties配置文件
- springboot 修改启动时默认加载application.properties文件以及加载指定配置文件
- 可以从Jar外部加载JDBC.properties的Spring-mybatis配置文件
- Spring加载properties配置资源文件的应用
- Spring学习总结(20)——Spring加载多个项目properties配置文件问题解决
- springboot 修改默认加载的配置文件不为application.properties
- 参数配置文件properties--使用spring加载和简化读取
- Spring配置中从外部文件加载多个properties文件
- spring boot:使用@ConfigurationProperties注解加载配置文件