spring 分散配置
Spring简化了加载资源文件的配置,可以通过<context:property-placeholder去加载,这个元素的写法如下:
<context:property-placeholder location="classpath:jdbc.properties"/>
如果想要配置多个properties文件
<context:property-placeholder location="classpath:jdbc1.properties"/> <context:property-placeholder location="classpath:jdbc2.properties"/>
这种方式是不被允许的,一定会出"Could not resolve placeholder"
解决方案:
(1) 在Spring 3.0中,可以写:
<context:property-placeholder location="xxx.properties" ignore-unresolvable="true"/> <context:property-placeholder location="xxx.properties" ignore-unresolvable="true"/>
(2) 但是在Spring 2.5中,<context:property-placeholder>没有ignore-unresolvable属性,所以就不能使用上面的那种方法去配置,可以改如下的格式:
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>classpath:/jdbc.properties</value> </list> </property> </bean>
spring 分散配置的更多相关文章
- spring_07使用spring的特殊bean、完成分散配置
一. 前言 分散配置思路:创建properties文件,添加数据,在beans文件中先配置properties文件,再在bean中使用占位符引用数据 对于bean的生命周期中的很多处理接口,处 ...
- 使用spring的特殊bean完成分散配置
1.在使用分散配置时,spring的配置文件applicationContext.xml中写法如下: <!-- 引入db.properties文件, --> <context:pro ...
- 基于SpringBoot的Environment源码理解实现分散配置
前提 org.springframework.core.env.Environment是当前应用运行环境的公开接口,主要包括应用程序运行环境的两个关键方面:配置文件(profiles)和属性.Envi ...
- Spring Boot -- 配置切换指南
一般在一个项目中,总是会有好多个环境.比如: 开发环境 -> 测试环境 -> 预发布环境 -> 生产环境 每个环境上的配置文件总是不一样的,甚至开发环境中每个开发者的环境可能也会有一 ...
- spring 定时任务配置
1.(易)如何在spring中配置定时任务? spring的定时任务配置分为三个步骤: 1.定义任务 2.任务执行策略配置 3.启动任务 (程序中一般我们都是到过写的,直观些) 1.定义任务 < ...
- 两种流行Spring定时器配置:Java的Timer类和OpenSymphony的Quartz
1.Java Timer定时 首先继承java.util.TimerTask类实现run方法 import java.util.TimerTask; public class EmailReportT ...
- Spring Cloud 配置服务
Spring Cloud 配置服务 1. 配置服务简介 产生背景: 传统开发中,我们通常是将系统的业务无关配置(数据库,缓存服务器)在properties中配置,在这个文件中不会经常改变,但随着系统规 ...
- spring事务配置详解
一.前言 好几天没有在对spring进行学习了,由于这几天在赶项目,没有什么时间闲下来继续学习,导致spring核心架构详解没有继续下去,在接下来的时间里面,会继续对spring的核心架构在继续进行学 ...
- spring MVC配置详解
现在主流的Web MVC框架除了Struts这个主力 外,其次就是Spring MVC了,因此这也是作为一名程序员需要掌握的主流框架,框架选择多了,应对多变的需求和业务时,可实行的方案自然就多了.不过 ...
随机推荐
- C++静态成员
类中的静态成员真是个让人爱恨交加的特性.我决定好好总结一下静态类成员的知识点,以便自己在以后面试中,在此类问题上不在被动. 静态类成员包括静态数据成员和静态函数成员两部分. 一 静态数据成员: 类体中 ...
- POJ 3259 Wormholes(SPFA+邻接表)
( ̄▽ ̄)" #include<iostream> #include<cstdio> #include<queue> #include<vector ...
- osgOcean测试
#include <osgViewer/Viewer> #include <osgDB/ReadFile> #include <osgGA/TrackballManipu ...
- GDI+ 图片转存
摘自MSDN,其中 GetEncoderClsid 第一个参数可为 L"image/bmp" L"image/jpeg" L"image/gif&qu ...
- asp下sha1加密函数
sha1.asp文件 <script language="javascript" type="text/javascript" runat="s ...
- hadoop性能测试命令
1.测试hadoop写的速度向HDFS文件系统中写入数据,10个文件,每个文件10MB,文件存放到/benchmarks/TestDFSIO/io_data中hadoop jar share/had ...
- Cross compile openwrt
在Centos7上交叉编译生成OpenWrt固件 安装ss-* 获取最新的ss, 当前是 wget https://github.com/shadowsocks/shadowsocks-libev/a ...
- Codeforces Round #350 (Div. 2)_D2 - Magic Powder - 2
D2. Magic Powder - 2 time limit per test 1 second memory limit per test 256 megabytes input standard ...
- 解析好的静态页面.shtml浏览器无法解析.需要apache解析后再返回给浏览器
解析好的静态页面.shtml浏览器无法解析.需要apache解析后再返回给浏览器 让Apache支持SHTML(SSI)的配置方法 http.conf放开addtype text/html .shtm ...
- how to use tar?
In UNIX, tar is the most useful tool to compress files (just like zip in Windows.) To compress, inpu ...