PropertyPlaceholderConfigurer achieve BeanFactoryPostProcessor interface, it is able to property values ??in the external management. Developers can provide a separate properties file management-related properties. For example, the following properties file exists, taken from userinfo.properties.

only in the spring configuration file to add one: to, where location is the location of the configuration file parameters, parameter configuration file is usually placed in the src directory, and the parameters of the configuration file format with java the same general configuration file parameters, namely in the form of key-value pairs, for example: < br />

< pre STYLE = "margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb (51, 51, 51); font-family: ourier new monospace; font-size: 12px; width: 591px; overflow-x: auto; overflow-y: auto; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb (230, 230, 230); background-position: initial initial; background-repeat: initial initial; "> < br />
: a, in the development stage we connect to the database connection url, username, password, driverClass other

expectations: can not have a solution that can help us in a stage does not require a parameter to write frequently, but in different stages and can easily switch between the parameters of configuration information

2. and these parameters are often required between the different stages of change

value =” $ {test.jdbc.driverClassName }”/>< br />
For example: In the delivery phase of the project development phase and the database connection information is often different, distributed application is the same situation.

period in the development of enterprise applications, or enterprise application deployment to a production environment, the application of information is often dependent on many parameters need to be adjusted, such as an LDAP connection, RDBMS
PropertyPlaceholderConfigurerDemo example by running and analyzing applications, developers are able to in-depth understanding of PropertyPlaceholderConfigurer. To simplify the use of PropertyPlaceholderConfigurer, Spring element provides a The following example shows the configuration, enable it, the developers would not configured PropertyPlaceholderConfigurer the object.
JDBC connection information. externalization of such information management is particularly important. PropertyPlaceholderConfigurer and PropertyOverrideConfigurer object, which is responsible for the external application of the configuration parameters of the task.

external The configuration of application parameters

application: < br />
defined in the configuration file so bean:
class = “org.springframework.jdbc.datasource.DriverManagerDataSource”>
line after the # part of comments

b, distributed applications, client-side access to server-side address used by the server, port, service, etc.

test.jdbc.driverClassName = com.mysql.jdbc.Driver

PropertyPlaceholderConfigurer built-in functions very rich, if it does not find $ {xxx} xxx key defined, it will go to the JVM system property (System.getProperty ()) and environmental variables (System.getenv ()) to find. systemPropertiesMode and searchSystemEnvironment properties by enabling , developers can control this behavior.

} This form of variables used in the spring which provides annotations for annotation properties to provide value
address: spring3 provide an easy way to context: property-placeholder / element

userinfo.properties
following is an excerpt from propertyplaceholderconfigurer.xml . Under normal circumstances, the definition does not appear userInfo $ {db.username}, $ {db.password} and other similar information used here PropertyPlaceholderConfigurer management username and password attributes values. DI container to instantiate userInfo before, PropertyPlaceholderConfigurer will modify the meta data information userInfo ( definition), it will use userinfo.properties scott corresponding value in db.username replace $ {db.username}, db.password corresponding tiger values ??with $ {db.password}. Ultimately, DI container to instantiate userInfo when, UserInfo will get the new property value, rather than $ {db.username}, $ {db.password} and other similar information.