spring propertyplaceholderconfigurer 讲解
来源:互联网 发布:淘宝前100名半价怎么抢 编辑:程序博客网 时间:2024/04/30 03:38
Spring的框架中为您提供了一个BeanFactoryPostProcessor的实体类别 org.springframework.beans.factory.config.PropertyPlaceholderConfigurer,
基于这个类别,您可以将一些组件设定,移出至.properties档案中,如此的安排可以让xml定义档负责系统关设定,而.properties档可以作为客户根据
需要,自定义一些相关的参
在使用Spring配置获取properties文件时,
下面实例参数
1:获取一个配置文件
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>classpath:/resourece/jdbc.properties</value>
</bean>
其中classpath是引用src目录下的文件写法
2:获取多个配置文件时,配置就需要使用locations
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<value>classpath:/com/.jdbc.properties</value>
<value>classpath:/com/config.properties</value>
<property>
</bean>
3:使用多个PropertyPlaceholderConfigurer来分散配置,达到整合多工程下的多个分散的Properties文件,其配置如下
<bean id="propertyConfigForProject1" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="order" value="1"/>
<property name="localtion">
<value>classpath:/com/mes.properties</value>
</property>
</bean>
<bean id="propertyConfigurerForProject2" class="org.springframework.beans.factory.config.PorpertyPlaceholderConfigurer">
<property name="order" value="2"/>
<property name="ignoreUnresolvablePlaceholders" value="true"/>
<property name="locations">
<list>
<value>classpath:/com/jdbc.properties</value>
<value>classpath:/com/config.properties</value>
</list>
<property>
其中order属性代表其加载顺序,而 inoreUnresolvablePlaceholders为是否忽略不可解析的Placeholder,如配置了多个propertyPlaceholderConfigurer,则需设置为true
- spring propertyplaceholderconfigurer 讲解
- Spring--PropertyPlaceholderConfigurer
- spring propertyplaceholderconfigurer
- Spring PropertyPlaceholderConfigurer
- spring PropertyPlaceholderConfigurer
- spring propertyplaceholderconfigurer
- spring propertyplaceholderconfigurer
- Spring PropertyPlaceholderConfigurer
- spring的好处--PropertyPlaceholderConfigurer
- spring的好处--PropertyPlaceholderConfigurer
- [Spring]PropertyPlaceholderConfigurer类相关
- Spring PropertyPlaceholderConfigurer Usage
- spring的 PropertyPlaceholderConfigurer配置
- Spring的PropertyPlaceholderConfigurer应用
- Spring容器扩展--PropertyPlaceholderConfigurer
- Spring配置之PropertyPlaceholderConfigurer
- Spring的PropertyPlaceholderConfigurer应用
- Spring PropertyPlaceholderConfigurer 自定义扩展
- Delphi 7 中使用Indy创建独立的 Web Services/SOAP 服务器(二)
- java中的数学计算函数
- 蚂蚁的难题(三)
- 微信的崛起与未来(随笔小记)
- 博客开通时刻
- spring propertyplaceholderconfigurer 讲解
- 平衡二叉树(AVL树)的实现
- Android ProgressBar ImageLoading 旋转进度值
- 【中断异常】页面异常的进入和返回
- 深入 char * ,char ** ,char a[ ] ,char *a[] 内核
- redhat5.8测试部署OracleRAC11G
- Target runtime Apache Tomcat v6.0 is not defined.错误解决方法
- TI C66x DSP 系统events及其应用 - 5.2(PDSP配置)
- 从源代码角度看Struts2返回JSON数据的原理