• 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"/>

  • 相关阅读:
    python3监控网站状态
    暴力屏蔽80访问失败的用户
    python3爬取中国药学科学数据
    python3发邮件脚本
    OOP AOP
    lambda
    jni
    Gradle史上最详细解析
    supersocket 遇到的Failed to initialize 和 log4net用法
    在c#中利用keep-alive处理socket网络异常断开的方法
  • 原文地址:https://www.cnblogs.com/shamo89/p/6674095.html
Copyright © 2020-2023  润新知