资源文件加载

来源:互联网 发布:济南网络系统集成商 编辑:程序博客网 时间:2024/04/28 19:28

主要通过spring的资源文件处理类:PropertyPlaceholderConfigurer

 

<bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations"> 
              <list> 
                     <value>classpath:conf/jdbc.properties</value> 
                     <value>classpath:conf/systemConfig.properties</value>

                      ... ...
               </list>
       </property>
</bean>

xml中用的时候通过${key}来使用,如遇到特殊场景,需要对值进行处理的,也可自定义类,该类继承PropertyPlaceholderConfigurer类即可,主要重写convertProperty(String propertyName, String propertyValue)方法

 

0 0
原创粉丝点击