Spring容器仅允许最多定义一个PropertyPlaceholderConfigurer
来源:互联网 发布:2014年十大网络流行语 编辑:程序博客网 时间:2024/06/03 13:51
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如果提供一个警告就好了)。
拿上来的例子来说,如果A和B模块是单独运行的,由于Spring容器都只有一个PropertyPlaceholderConfigurer, 因此属性文件会被正常加载并替换掉。如果A和B两模块集成后运行,Spring容器中就有两个 PropertyPlaceholderConfigurer Bean了,这时就看谁先谁后了, 先的保留,后的忽略!因此,只加载到了一个属性文件,因而造成无法正确进行属性替换的问题。
咋解决呢?
通配符解决
<context:property-placeholder location="classpath*:conf/conf*.properties"/>
把a.properties和b.properties都放到conf下面去。使用上面一行配置即可。
- Spring容器仅允许最多定义一个PropertyPlaceholderConfigurer
- Spring容器扩展--PropertyPlaceholderConfigurer
- Spring容器扩展点-PropertyPlaceholderConfigurer类
- Spring--PropertyPlaceholderConfigurer
- spring propertyplaceholderconfigurer
- Spring PropertyPlaceholderConfigurer
- spring PropertyPlaceholderConfigurer
- spring propertyplaceholderconfigurer
- spring propertyplaceholderconfigurer
- Spring PropertyPlaceholderConfigurer
- 系统启动PropertyPlaceholderConfigurer加载配置到spring容器中
- spring的好处--PropertyPlaceholderConfigurer
- spring的好处--PropertyPlaceholderConfigurer
- [Spring]PropertyPlaceholderConfigurer类相关
- Spring PropertyPlaceholderConfigurer Usage
- spring的 PropertyPlaceholderConfigurer配置
- Spring的PropertyPlaceholderConfigurer应用
- Spring配置之PropertyPlaceholderConfigurer
- CRC8
- 数据结构-查找二叉树(Binary Sort Tree)
- 频谱细化(补零、zfft、czt)
- /usr 的由来及/usr目录结构
- maven项目 jre system library 1.5-->1.7,或者是任意版本,终极解决方案!!
- Spring容器仅允许最多定义一个PropertyPlaceholderConfigurer
- 第一个颗博客
- Node.js学习笔记(一)基础介绍
- OpenCV模块库简单介绍
- 强制IE浏览器或WebBrowser控件使用指定版本显示网页
- pureftp部署和优化-1
- SourceInsight安装
- LeetCode题目1
- 并查集 数据结构