Brief analysis of Propertyplaceholderconfigurer class under Spring Frame [reprint]

Source: Internet
Author: User

To understand this class first you need to figure out a concept: Bean factory Post-processor
The official explanation is this:
A bean factory Post-processor is a Java class which implements the
Org.springframework.beans.factory.config.BeanFactoryPostProcessor interface. It is executed manually (in the case of the Beanfactory) or automatically (in the case of the ApplicationContext) to APPL Y changes of some sort to a entire beanfactory, after it had been constructed.
I understand the meaning of this:
1. First The Bean factory Post-processor implements the Org.springframework.beans.factory.config.BeanFactoryPostProcessor interface.
2. In the case of beanfactory it is executed manually.
3. It will execute automatically under applicationcontext conditions.
4. The most critical point is that after an instance of a class is constructed, the entire beanfactory is modified.
Then the Propertyplaceholderconfigurer class is a bean factory post-processor, its role is a resource property of the Configurator, The ability to place content defined in the beanfactory in a file with the. propertis suffix.
For example

${driver}
Jdbc:${dbname}

and the actual Jdbc.propertis file is
Jdbc.driverclassname=org.hsqldb.jdbcdriver
jdbc.url=jdbc:hsqldb:hsql://production:9002
Jdbc.username=sa
Jdbc.password=root
And how Jdbc.propertis is quoted:
---spring-context.xml----



/web-inf/jdbc.properties



Registering the upper section of the configuration in Web. XML is possible

Contextconfiglocation
/web-inf/spring-context.xml

Of course, don't forget spring's listener registration


Org.springframework.web.context.ContextLoaderListener


In this way, a simple data source is set up.
In fact, the role of Propertyplaceholderconfigurer is to place the database configuration information pointed to by the placeholder in the bean definition
The tool.

Brief analysis of Propertyplaceholderconfigurer class under Spring Frame [reprint]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.