Spring 中 PropertyPlaceholderConfigurer 的使用
来源:互联网 发布:enum java 用法 编辑:程序博客网 时间:2024/05/09 21:07
A property resource configurer that resolves placeholders in bean property values of context definitions. It pulls values from a properties file into bean definitions.
The default placeholder syntax follows the Ant / Log4J / JSP EL style:
${...}
Example XML context definition:
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName"><value>${driver}</value></property> <property name="url"><value>${dbname}</value></property> </bean>
Example properties file:
driver=com.mysql.jdbc.Driver dbname=mysql:mydb
PropertyPlaceholderConfigurer checks simple property values, lists, maps, props, and bean names in bean references. Furthermore, placeholder values can also cross-reference other placeholders, like:
rootPath=myrootdirsubPath=${rootPath}/subdir
In contrast to PropertyOverrideConfigurer, this configurer allows to fill in explicit placeholders in context definitions. Therefore, the original definition cannot specify any default values for such bean properties, and the placeholder properties file is supposed to contain an entry for each defined placeholder.
If a configurer cannot resolve a placeholder, a BeanDefinitionStoreException will be thrown. If you want to check against multiple properties files, specify multiple resources via the "locations" setting. You can also define multiple PropertyPlaceholderConfigurers, each with its own placeholder syntax.
Default property values can be defined via "properties", to make overriding definitions in properties files optional. A configurer will also check against system properties (e.g. "user.dir") if it cannot resolve a placeholder with any of the specified properties. This can be customized via "systemPropertiesMode".
Note that the context definition is aware of being incomplete; this is immediately obvious to users when looking at the XML definition file. Hence, placeholders have to be resolved; any desired defaults have to be defined as placeholder values as well (for example in a default properties file).
Property values can be converted after reading them in, through overriding the PropertyResourceConfigurer.convertPropertyValue(java.lang.String)
method. For example, encrypted values can be detected and decrypted accordingly before processing them.
- Spring 中 PropertyPlaceholderConfigurer 的使用
- Spring中PropertyPlaceholderConfigurer的使用
- Spring中PropertyPlaceholderConfigurer的使用
- Spring中PropertyPlaceholderConfigurer的使用
- Spring中PropertyPlaceholderConfigurer的使用
- Spring中PropertyPlaceholderConfigurer的使用
- Spring中PropertyPlaceholderConfigurer的使用
- spring中PropertyPlaceholderConfigurer的使用
- Spring中PropertyPlaceholderConfigurer的使用
- Spring中PropertyPlaceholderConfigurer的使用(一)
- Spring中PropertyPlaceholderConfigurer的使用(二)
- Spring中PropertyPlaceholderConfigurer的使用(一)
- Spring中PropertyPlaceholderConfigurer的使用介绍
- Spring中PropertyPlaceholderConfigurer的使用(一)
- spring中PropertyPlaceholderConfigurer和PropertyOverrideConfigurer的使用
- Spring PropertyPlaceholderConfigurer的使用
- Spring PropertyPlaceholderConfigurer的使用
- spring propertyplaceholderconfigurer的使用
- SQLServer里10万的表成为运行瓶颈的问题
- 论企业管理之员工管理
- Iterator Pattern(迭代器模式)
- gcc默认支持的文件扩展名
- 《JavaScript凌厉开发 Ext详解与实践》3月5日开始上架销售
- Spring 中 PropertyPlaceholderConfigurer 的使用
- ARM处理器系统初始化过程
- 浅谈ETag
- eclipse下安装JS插件 ,Spket(ext)
- 郁闷
- freemarker pk velocity
- 树结构
- 验证码
- jasperreport_ireport集成与使用