Properties if loaded through Propertyplaceholderconfigurer in spring, you can take advantage of some of the key and value values in the properties that are needed in spring porpertyplace Holderconfiger provides direct access to the $.
Porpertyplaceholderconfiger has some common properties that may be used in some advanced applications
- Locations
- fileencoding the encoding format of the properties file
- If more than one propertyplaceholderconfigurer is defined in the order file, this property specifies the precedence order.
- The Placeholderprefix default prefix placeholder is "${". You can change to a different prefix as needed. --- This feature estimate is the reason that spring can use ${xxx} to get the contents of the properties file, that is, it is estimated that spring will see the ${placeholder in Propertyplaceholderconfigurer to find The properties file it loads, so that spring can use ${} to obtain property values in the attributes.
- Placeholdersuffix The default suffix placeholder is "}".
- Because Propertyplaceholderconfigurer has a very rich built-in feature, if it does not find the XXX key defined in ${xxx}, it also goes to the JVM System Properties (System.getproperty () ) and Environment variables (system.getenv ()). By enabling the Systempropertiesmode and Searchsystemenvironment properties, developers can control this behavior.
- ${} can also be used directly on Java beans on the class, see: Http://www.cnblogs.com/wzhanke/p/4838890.html
Examples are as follows:
<bean
class= "Org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" ><property name= "Locations" ><list><value>classpath*:* .properties</value></list></property></bean> <bean id= "DataSource" class= "Com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method= "Close" > <property Name= "Driverclass" value= "${driverclass}" ></property>---> indicates that the properties file has Driverclass = AAA, via ${ Driverclass} will be able to get AAA value <property name= "Jdbcurl" value= "${url}" ></property></bean>
Instructions for reading the properties file with ${xxx} in Spring