• spring bean的分散配置(a.properties文件读取的第四种方式)


    见韩顺平的spring 第12讲

    她 把原本需要在<bean><property name="${username}" value="${password}"/><bean> 中配置的property放在一个a.properties文件中,自己通过el表达式取值。

    其中,a.properties的初始化通过spring 提供的特殊bean ----PropertyPlaceHolderConfigure(分散配置bean)来处理。不需要写什么,只需要配置下下就好了:<bean class="org....PropertyPlaceHolderConfigure">

                <property name="locations">

                  <list>

                    <value>com/test/properties/a.properties</value>

                    <value>com/test/properties/b.properties</value>

                  </list>

                </property>

              </bean>

    更简单的配置: <context:property-placeholder location="com/test/properties/a.properties,com/test/properties/a.properties"/> 即可

    补充:四种获得a.properties 里面值的方法

    1. ResourceBundle,见我博客

    2.filter 继承类咯有个fiterConfig,见上篇博客

    3.propertiesConfiguration

    4.此篇

  • 相关阅读:
    openlayers跨域设置后出现http status 500错误
    myeclipse 2014 闪退问题解决
    html跨域获取数据
    centos的nginx支持ssl
    Hadoop学习笔记---HDFS
    Nginx Web服务器配置
    用ReentrantLock和Condition实现线程间通信
    Android绘图机制和处理技巧
    自定义ViewPagerIndicator-视图指示器
    Docker学习笔记
  • 原文地址:https://www.cnblogs.com/yanjunwu/p/3000456.html
Copyright © 2020-2023  润新知