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、BeanFactoryPostProcessors are installed and invoked, processing bean definitions.
5、BeanPostProcessors are installed.
6、Beans are instantiated according to the bean definitions. BeanPostProcessors are applied.
而PropertySourcesPlaceholderConfigurer 是一个BeanFactoryPostProcessor,这样的话,import必然发生在BeanPostProcessors 之前,也就无法解析。这是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 ...
随机推荐
- HDU 1240 (简单三维广搜) Asteroids!
给出一个三维的迷宫以及起点和终点,求能否到大终点,若果能输出最短步数 三维的问题无非就是变成了6个搜索方向 最后强调一下xyz的顺序,从输入数据来看,读入的顺序是map[z][x][y] 总之,这是很 ...
- Jquery源码中的Javascript基础知识(四)— jQuery.fn.init方法
$() 即调用了jQuery.fn.init方法 jQuery = function( selector, context ) { return new jQuery.fn.init( selecto ...
- hibernate一个注册小例子
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAXUAAAJ2CAIAAAAv44WsAAAgAElEQVR4nO29a3QUVaL33fPhfHrW8y
- hihoCoder #1179 : 永恒游戏 (暴力枚举)
题意: 给出一个有n个点的无向图,每个点上有石头数个,现在的游戏规则是,设置某个点A的度数为d,如果A点的石子数大于等于d,则可以从A点给每个邻接点发一个石子.如果游戏可以玩10万次以上,输出INF, ...
- 【转】发布的QT程序无法显示图标和图片的问题
在windows下编译好的QT程序在其他没有安装QT的机器上会出现图标和图片无法正常显示的问题. 这时我们可以通过以下方式来解决: 在release文件夹里创建plugins文件夹,并将QT安装目录下 ...
- 深入学习Heritrix---解析CrawlController(转)
当我们以Web UI方式使用Heritrix时,点击任务开始(start)按钮时,Heritrix就开始了它的爬取工作.但它的内部 执行流程是怎样的呢?别急,下面将慢慢道来. (一)CrawlJobH ...
- Java中传值与传引用
不管Java参数类型是什么,一律传递参数的副本. <Thinking In Java>:“When you're passing primitives into a method,you ...
- OpenLayers调用arcgis server发布的地图服务
有两种方式可以调用arcgis server发布的地图服务,一种是rest,一种是wms. 地图的投影为900913,arcgis server为10.0版本,地图服务的空间参考为3857. 与 ...
- web-3g-(163)网易-邮箱-记事本-数据库设计
ylbtech-DatabaseDesgin:ylbtech-cnblogs(博客园)-数据库设计-2,Admin(用户后台) DatabaseName:cnblogs(博客园) Model:Admi ...
- angularJS+requireJS并集成karma测试实践
最近在为下一个项目做前端技术选型,Angular是必须要用的(BOSS指定,个人感觉也不错,开发效率会很高).由于需要加载的JS很多,所以打算看看angular和requirejs一起用会怎么样.在g ...