Context:property-placeholder import of multiple standalone profiles in spring

Source: Internet
Author: User

Context:property-placeholder import multiple standalone. Properties Profiles in spring?

The spring container uses the discovery mechanism of reflection scanning, which has a org.springframework.beans.factory.config.PropertyPlaceholderConfigurer in the detection of spring containers. The bean will stop scanning the remaining propertyplaceholderconfigurer (Spring 3.1 has used propertysourcesplaceholderconfigurer instead Propertyplaceholderconfigurer).


in other words, the spring container allows only a maximum of one propertyplaceholderconfigurer (or <context:property-placeholder/>) to be defined, The rest will be ignored by spring (in fact, if spring provides a warning).

For example, if the A and B modules are running separately, because the spring container has only one propertyplaceholderconfigurer, the properties file will be loaded and replaced normally. If the A and B two modules are integrated and run, there are two propertyplaceholderconfigurer beans in the spring container, and then look who first who is behind, the first reservation, after the neglect! As a result, only one property file is loaded, resulting in an issue where property substitution cannot be performed correctly.


How to solve it?

Wildcard resolution

< Context:property-placeholder location ="Classpath*:conf/conf*.properties"/>

Context:property-placeholder import of multiple standalone profiles in spring

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.