spring properties resolve 问题
在stackoverflow上看到一个问题
配置如下:
<context:property-placeholder location="/WEB-INF/application-customer-dev.properties,classpath:application-customer.properties" ignore-resource-not-found="true"/>
<import resource="classpath*:com/x/core/security/security-${login.security}.xml"/>
在application-customer.properties中有配置项:
login.security=dev
可是import却没能按照期望的发生。
解释如下:
大概spring context解析过程如下:
Basically Spring XML context setup goes more or less like this:
1、Context is created.
2、Environment
is set.
3、XML is read (all XML, resolving imports if necessary). Bean definitions are created.
4、BeanFactoryPostProcessor
s are installed and invoked, processing bean definitions.
5、BeanPostProcessor
s are installed.
6、Beans are instantiated according to the bean definitions. BeanPostProcessors are applied.
而PropertySourcesPlaceholderConfigurer
是一个BeanFactoryPostProcessor,这样的话,import必然发生在
BeanPostProcessor
s 之前,也就无法解析。这是spring硬编码的,你无法改变。
spring properties resolve 问题的更多相关文章
- Spring properties dependency checking
In Spring,you can use dependency checking feature to make sure the required properties have been set ...
- [Spring] Properties for project configuration
We might have some project specific configuration need to setup. The good approach to do this in Spr ...
- 【Spring源码分析】.properties文件读取及占位符${...}替换源码解析
前言 我们在开发中常遇到一种场景,Bean里面有一些参数是比较固定的,这种时候通常会采用配置的方式,将这些参数配置在.properties文件中,然后在Bean实例化的时候通过Spring将这些.pr ...
- Spring boot 配置文件详解 (properties 和yml )
从其他框架来看 我们都有自己的配置文件, hibernate有hbm,mybatis 有properties, 同样, Spring boot 也有全局配置文件. Springboot使用一个全局的配 ...
- eclips环境下开发spring boot项目,application.properties配置文件下中文乱码解决方案
如以上,application.properties文件下中文乱码.发生乱码一般都是由于编码格式不一样导致的. 打开Window-Preferences-General-content Types-T ...
- spring boot项目,application.properties配置文件下中文乱码解决方案
转自:https://blog.csdn.net/qq_40408534/article/details/79831807 如以上,application.properties文件下中文乱码.发生乱码 ...
- Java-马士兵设计模式学习笔记-工厂模式-模拟Spring读取Properties文件
一.目标:读取properties文件,获得类名来生成对象 二.类 1.Movable.java public interface Movable { void run(); } 2.Car.java ...
- Spring 中无处不在的 Properties
转自:https://javadoop.com/post/spring-properties?hmsr=toutiao.io&utm_medium=toutiao.io&utm_sou ...
- 译:Spring框架参考文档之IoC容器(未完成)
6. IoC容器 6.1 Spring IoC容器和bean介绍 这一章节介绍了Spring框架的控制反转(IoC)实现的原理.IoC也被称作依赖注入(DI).It is a process wher ...
随机推荐
- Qt Assistant介绍
简介 Qt Assistant也就是我们常说的Qt助手,是一款用于呈现在线文档的工具. 简介 一分钟学会使用 Qt参考文档 Qt Assistant详解 命令行选项 工具窗口 文档窗口 工具栏 菜单 ...
- Qt Creator介绍
简介 Qt Creator是使用Qt开发的IDE.Qt支持Windows.Linux/Unix.Mac OS X.Android.BlackBerry.QNX等多种平台,Qt Creator为不同平台 ...
- Web程序员最常用的11款PHP框架
PHP框架是Web程序员和开发人员最为有用的工具. PHP框架可以帮助用户更快地开发项目. 今天我将为开发人员带来几款最好的PHP框架,希望能对你有用. 1.Agavi Agavi是一款强大的,可扩展 ...
- Swustoj题目征集计划
SWUST OJ题目征集计划 鉴于SWUST OJ长时间没有新题添加,题目数量和类型有限,同时也为加强同学们之间的算法交流,享受互相出题AC的乐趣,提高算法水平,现在启动题目征集计划啦~ 当你遇到 ...
- 在view中常见的四种方法的使用场合
四种方法,使view创建好里面就有东西:[1.init 2.initWithFrame使用代码创建的时候.(从文件创建的时候不一定调用:1.init 2.initWithFrame这两个方法) 3 ...
- 点分十进制IP校验、转换,掩码校验
/***************************************************************************** * 点分十进制IP校验.转换,掩码校验 * ...
- 09day2
多米诺骨牌 递推+高精度 [问题描述] Jzabc 对多米诺骨牌有很大兴趣,然而他的骨牌比较特别,只有黑色的和白色的两种.他觉得如果存在连续三个骨牌是同一种颜色,那么这个骨牌排列便是不美观的.现在他有 ...
- 【英语】Bingo口语笔记(21) - 表达“请客吃饭”
- 《C++ Primer 4th》读书笔记 序
注:本系列读书笔记是博主写作于两三年前的,所以是基于<C++ Primer>第四版的,目前该书已更新至第五版,第五版是基于C++11标准的,貌似更新挺多的.博主今年应届硕士毕业,如若过阵子 ...
- 《C和指针》读书笔记 第5章-操作符和表达式
原创文章,转载请注明出处:http://www.cnblogs.com/DayByDay/p/3936503.html