zoukankan      html  css  js  c++  java
  • spring配置文件中context:property-placeholder导入多个独立的配置文件

    spring中 context:property-placeholder 导入多个独立的 .properties配置文件?

    Spring容器采用反射扫描的发现机制,在探测到Spring容器中有一个 org.springframework.beans.factory.config.PropertyPlaceholderConfigurer的 Bean就会停止对剩余PropertyPlaceholderConfigurer的扫描(Spring 3.1已经使用PropertySourcesPlaceholderConfigurer替代 PropertyPlaceholderConfigurer了)。

    换句话说,即Spring容器仅允许最多定义一个PropertyPlaceholderConfigurer(或<context:property-placeholder/>),其余的会被Spring忽略掉(其实Spring如果提供一个警告就好了)

    举个例子,applicationContext.xml文件中需要导入jdbc.properties和redis.properties两个配置文件,

    那这样写是不行的,只能识别到jdbc.properties

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

    咋解决呢?

    通配符解决

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

  • 相关阅读:
    浅析http缓存
    多级路由请求js文件路径不对的解决方法
    移动端屏幕适配原理以及方法讲解
    zoom与scale的异同
    querySelectorAll选择器的js实现
    垂直居中效果汇总
    windows配置php开发环境
    CentOS 6.2安装nagios
    Ganglia安装
    Ubuntu 14.04上安装Riak
  • 原文地址:https://www.cnblogs.com/shamo89/p/6674095.html
Copyright © 2011-2022 走看看