zoukankan      html  css  js  c++  java
  • 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.此篇

  • 相关阅读:
    Shell基础:变量类型 & 运算符
    Ant基础入门
    Shell基础:Shell和Mysql交互
    Linux配置邮箱发送(MUTT/MSMTPQ)
    [转载]JMeter源码导入Eclipse
    [转载]Badboy使用教程
    工程目录 Java/Web/Maven
    Maven基础知识和环境搭建
    Github/Eclipse管理Maven项目
    Git分支管理详解
  • 原文地址:https://www.cnblogs.com/yanjunwu/p/3000456.html
Copyright © 2011-2022 走看看