Spring中PropertyPlaceholderConfigurer的使用
2013-05-06 10:16
471 查看
基本的使用方法是:
<bean id="propertyConfigurerForAnalysis" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>classpath:/spring/include/dbQuery.properties</value>
</property>
</bean>
其中classpath是引用src目录下的文件写法。
当存在多个Properties文件时,配置就需使用locations了:(2)
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:/spring/include/jdbc-parms.properties</value>
<value>classpath:/spring/include/base-config.properties</value>
</list>
</property>
</bean>
接下来我们要使用多个PropertyPlaceholderConfigurer来分散配置,达到整合多工程下的多个分散的Properties 文件,其配置如下:(3)
<bean id="propertyConfigurerForProject1" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="order" value="1" />
<property name="ignoreUnresolvablePlaceholders" value="true" />
<property name="location">
<value>classpath:/spring/include/dbQuery.properties</value>
</property>
</bean>
<bean id="propertyConfigurerForProject2" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="order" value="2" />
<property name="ignoreUnresolvablePlaceholders" value="true" />
<property name="locations">
<list>
<value>classpath:/spring/include/jdbc-parms.properties</value>
<value>classpath:/spring/include/base-config.properties</value>
</list>
</property>
</bean>
其中order属性代表其加载顺序,而ignoreUnresolvablePlaceholders为是否忽略不可解析的 Placeholder,如配置了多个PropertyPlaceholderConfigurer,则需设置为true
<bean id="propertyConfigurerForAnalysis" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>classpath:/spring/include/dbQuery.properties</value>
</property>
</bean>
其中classpath是引用src目录下的文件写法。
当存在多个Properties文件时,配置就需使用locations了:(2)
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:/spring/include/jdbc-parms.properties</value>
<value>classpath:/spring/include/base-config.properties</value>
</list>
</property>
</bean>
接下来我们要使用多个PropertyPlaceholderConfigurer来分散配置,达到整合多工程下的多个分散的Properties 文件,其配置如下:(3)
<bean id="propertyConfigurerForProject1" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="order" value="1" />
<property name="ignoreUnresolvablePlaceholders" value="true" />
<property name="location">
<value>classpath:/spring/include/dbQuery.properties</value>
</property>
</bean>
<bean id="propertyConfigurerForProject2" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="order" value="2" />
<property name="ignoreUnresolvablePlaceholders" value="true" />
<property name="locations">
<list>
<value>classpath:/spring/include/jdbc-parms.properties</value>
<value>classpath:/spring/include/base-config.properties</value>
</list>
</property>
</bean>
其中order属性代表其加载顺序,而ignoreUnresolvablePlaceholders为是否忽略不可解析的 Placeholder,如配置了多个PropertyPlaceholderConfigurer,则需设置为true
相关文章推荐
- spring propertyplaceholderconfigurer的使用
- Spring配置文件中使用PropertyPlaceholderConfigurer配置获取jdbc的配置信息
- Spring中PropertyPlaceholderConfigurer的使用
- spring中PropertyPlaceholderConfigurer和PropertyOverrideConfigurer的使用
- Spring中PropertyPlaceholderConfigurer的使用(一)
- spring使用PropertyPlaceholderConfigurer扩展来满足不同环境的参数配置
- Spring中PropertyPlaceholderConfigurer的使用
- Spring中PropertyPlaceholderConfigurer的使用(一)
- Spring中PropertyPlaceholderConfigurer的使用
- Spring中PropertyPlaceholderConfigurer的使用
- 在 Spring.NET 中使用 PropertyPlaceholderConfigurer 设置配置参数
- Spring的PropertyPlaceholderConfigurer使用
- Spring中PropertyPlaceholderConfigurer的使用
- Spring中PropertyPlaceholderConfigurer的使用
- Spring中PropertyPlaceholderConfigurer的使用
- spring使用多个PropertyPlaceholderConfigurer的配置
- Spring中PropertyPlaceholderConfigurer的使用
- Spring中使用 PropertyPlaceholderConfigurer 替换xml配置文件中的Bean配置项
- 使用 Spring Boot 快速构建 Spring 框架应用,PropertyPlaceholderConfigurer
- spring3+mybatis 使用MapperScannerConfigurer时context:property-placeholder载不进属性