其实我们可以完全不使用  context:property-placeholder  ,而是使用 PropertySourcesPlaceholderConfigurer :

    <bean class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">
<property name="location">
<value>app.properties</value>
</property>
<property name="ignoreUnresolvablePlaceholders" value="true"/>
</bean>

注意,其中的locations 不能这么写:

<property name="location">
<list>
<value>classpath:foo.properties</value>
</list>
</property>

需要把其中的list 去掉, 也没有深究为什么。 大概是spring 版本问题吧

根据前面的分析,我们知道,其实property-placeholder就是用到了 PropertySourcesPlaceholderConfigurer。

    <context:property-placeholder location="appa.properties,app.properties"/>

对比可知, 其实property-placeholder 简单了很多, 其实property-placeholder  就是一个简化写法。

两者是可以共存的, 每个都会对 所有的 bean 定义全部的循环 尝试做替换处理。所以最好不要同时写两个, 这样会效率比较低, 而是把 多个properties文件配置在其中一个 地方, 用逗号分开。

参考:

https://dzone.com/articles/properties-spring

spring 之 property-placeholder 分析2的更多相关文章

  1. Spring IOC 源码分析

    Spring 最重要的概念是 IOC 和 AOP,本篇文章其实就是要带领大家来分析下 Spring 的 IOC 容器.既然大家平时都要用到 Spring,怎么可以不好好了解 Spring 呢?阅读本文 ...

  2. Spring Ioc源码分析系列--Ioc源码入口分析

    Spring Ioc源码分析系列--Ioc源码入口分析 本系列文章代码基于Spring Framework 5.2.x 前言 上一篇文章Spring Ioc源码分析系列--Ioc的基础知识准备介绍了I ...

  3. spring事务源码分析结合mybatis源码(三)

    下面将结合mybatis源码来分析下,这种持久化框架是如何对connection使用,来达到spring事务的控制. 想要在把mybatis跟spring整合都需要这样一个jar包:mybatis-s ...

  4. Spring依赖注入原理分析

    在分析原理之前我们先回顾下依赖注入的概念: 我们常提起的依赖注入(Dependency Injection)和控制反转(Inversion of Control)是同一个概念.具体含义是:当某个角色( ...

  5. spring整合mybatis步骤分析

    1.spring配置datasource bean的时候,不同的数据库连接方式有有不同的datasource实现类. 比如采用c3p0数据库连接池,要用c3p0的datasource实现类 com.m ...

  6. Spring事务管理全面分析

    Spring 事务属性分析什么是事物  事务管理对于企业应用而言至关重要.它保证了用户的每一次操作都是可靠的,即便出现了异常的访问情况,也不至于破坏后台数据的完整性.就像银行的自助取款机,通常都能正常 ...

  7. Spring Boot源码分析-配置文件加载原理

    在Spring Boot源码分析-启动过程中我们进行了启动源码的分析,大致了解了整个Spring Boot的启动过程,具体细节这里不再赘述,感兴趣的同学可以自行阅读.今天让我们继续阅读源码,了解配置文 ...

  8. 精尽Spring MVC源码分析 - ViewResolver 组件

    该系列文档是本人在学习 Spring MVC 的源码过程中总结下来的,可能对读者不太友好,请结合我的源码注释 Spring MVC 源码分析 GitHub 地址 进行阅读 Spring 版本:5.2. ...

  9. 5.2 Spring5源码--Spring AOP源码分析二

    目标: 1. 什么是AOP, 什么是AspectJ 2. 什么是Spring AOP 3. Spring AOP注解版实现原理 4. Spring AOP切面原理解析 一. 认识AOP及其使用 详见博 ...

  10. 5.2 spring5源码--spring AOP源码分析二--切面的配置方式

    目标: 1. 什么是AOP, 什么是AspectJ 2. 什么是Spring AOP 3. Spring AOP注解版实现原理 4. Spring AOP切面原理解析 一. 认识AOP及其使用 详见博 ...

随机推荐

  1. Verilog HDL按位操作符与归约操作符的区别

    sdaPipe <= {`DEB_I2C_LEN{1'b1}}; {{}} 为一种赋值运算符,将一个表达式放入双重花括号中,而复制因子放在第一层花括号中,用来指定复制的次数. { }表示拼接,{ ...

  2. Tomcat version 7.0 only supports J2EE 1.2, 1.3, 1.4, and Java EE 5 Web modules

    原文出处:http://jingwang0523.blog.163.com/blog/static/9090710320113294551497/ 最近在用eclipse做项目,新建项目时什么都贪新, ...

  3. 移动web总结

    Meta标签:   1 <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-sc ...

  4. 在Struts.xml中的result元素指的是:指定动作类的动作方法执行完后的结果视图.

    result结果集 上一篇文章主要讲Struts2框架(4)---Action类访问servlet这篇主要讲result结果集 在Struts.xml中的result元素指的是:指定动作类的动作方法执 ...

  5. “必须执行Init_Clk函数,才能采集到二氧化碳接口485数据的问题”的解决

    这个问题困扰了我很长一段时间,而且如果这个问题不解决,就有一个无法调和的矛盾:执行Init_Clk函数,能采集到二氧化碳接口485数据,但是功耗大:不执行Init_Clk函数,不能采集到二氧化碳接口4 ...

  6. 为什么要将Apache与Tomcat集成?(或不)

    Why should I integrate Apache with Tomcat? (or not) There are many reasons to integrate Tomcat with ...

  7. Reasoning With Neural Tensor Networks For Knowledge Base Completion-paper

    https://www.socher.org/index.php/Main/ReasoningWithNeuralTensorNetworksForKnowledgeBaseCompletion 年份 ...

  8. js 数字随机滚动(数字递增)

    HTML: <div class="textMon"> <img src="./img/20180830160315.png" alt=&qu ...

  9. CocosCreator引擎修改与定制

    1.CCGame.js 修改部分数据脚本的加载时机,避免首屏卡顿 // Load game scripts var jsList = config[CONFIG_KEY.jsList]; if (js ...

  10. PythonStudy1——Python 值拷贝 浅拷贝 深拷贝

    拷贝:对值进行复制的过程 # 值拷贝:应用场景最多  ls = [1, 'abc', [10]] ls1 = ls # ls1直接将ls中存放的地址拿过来  # ls内部的值发生任何变化,ls1都会随 ...