zoukankan      html  css  js  c++  java
  • context:property-placeholder作用

    原文地址:http://blog.sina.com.cn/s/blog_a0de59cf0101dqeb.html

    spring去加载,这个元素的写法如下:

    <context:property-placeholder location="classpath:jdbc.properties"/>

    如果想要配置多个properties文件

    <context:property-placeholder location="classpath:jdbc.properties"/>

    <context:property-placeholder location="classpath:jdbc.properties"/>

    这种方式是不被允许的,一定会出"Could not resolve placeholder"

    解决方案:

    (1) Spring 3.0中,可以写:

    <context:property-placeholder location="xxx.properties" ignore-unresolvable="true"/>

    <context:property-placeholder location="xxx.properties" ignore-unresolvable="true"/>

    (2) 但是Spring 2.5中,没有ignore-unresolvable属性,所以就不能使用上面的那种方法去配置,

    可以改如下的格式:

    <bean id="propertyConfigurer"

    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">

    <property name="locations">

    <list>

    <value>classpath:/jdbc.properties</value>

    </list>

    </property>

    </bean>

  • 相关阅读:
    botzone Tetris2
    NOIP2017游记
    城乡联谊胡策会糊厕R3
    SRM 20
    AtCoder Regular Contest 082
    AtCoder Grand Contest 019
    复数模版
    SRM13
    NOI2017&&codeM2017游记
    java多线程编程
  • 原文地址:https://www.cnblogs.com/sharpest/p/7476673.html
Copyright © 2011-2022 走看看