Multiple resource files Ignoreunresolvableplaceholders configuration under multiple projects in Spring _spring

Source: Internet
Author: User

Cases or the same situation can be referred to

http://blog.csdn.net/z69183787/article/details/53423304


<bean id= "Propertyconfigurerforanalysis" class= " Org.springframework.beans.factory.config.PropertyPlaceholderConfigurer ">
<property name= "Location" >
<value>classpath:/spring/include/dbQuery.properties</value>
</property>
</bean>
The classpath is a reference to the SRC directory of the file.

When multiple properties files exist, the configuration will need to use locations: (2)

<bean id= "Propertyconfigurer" class= "Org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" > <property name= "Locations" >
<list>
<value>classpath:/spring/include/jdbc-parms.properties</value>
<value>classpath:/spring/include/base-config.properties</value>
</list>
</property>
</bean>
Next we have to use multiple propertyplaceholderconfigurer to distribute the configuration, to achieve the integration of multiple projects under a number of decentralized properties files, the configuration is as follows: (3)
<bean id= "PropertyConfigurerForProject1" class= " Org.springframework.beans.factory.config.PropertyPlaceholderConfigurer ">
<property name= "Order" value= "1"/>
<property name= "Ignoreunresolvableplaceholders" value= "true"/>
<property name= "Location" >
<value>classpath:/spring/include/dbQuery.properties</value>
</property>

</bean>


 <bean id= "PropertyConfigurerForProject2" class= " Org.springframework.beans.factory.config.PropertyPlaceholderConfigurer ">
    <property name=" Order "value=" 2 "/>
    <property name=" Ignoreunresolvableplaceholders "value=" true "/>
&nbs P   <property name= "Locations" >
      <list>
        <value >classpath:/spring/include/jdbc-parms.properties</value>
        <value> Classpath:/spring/include/base-config.properties</value>
      </list>
    </property>
</bean>
 
where the order attribute represents its load sequence, The ignoreunresolvableplaceholders is set to True
if you have configured more than one propertyplaceholderconfigurer to ignore the unresolved placeholder. This one true has been killing me for two days. Avoid the current placeholder throw an exception. To enter the next placeholder for property assignment.

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.