首先在配置文件中配置PropertyPlaceholderConfigurer

单个配置文件: 
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">  
  <property name="locations" value="classpath:com/foo/jdbc.properties"/>  
</bean>  
多个配置文件: 
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> 
  <property name="locations"> 
    <list>            
        <value>classpath:jdbc.properties</value> 
        <value>classpath:config.properties</value> 
   </list>
</property> 
</bean>

然后在需要的地方直接以下方式引用: 
<property name="url" value="${jdbc.url}"/>

spring读取properties的方法的更多相关文章

  1. 如何通过Spring读取Properties文件

    1 在Spring中配置文件中, 配置配置文件的引用     <util:properties id="settings" location="/WEB-INF/c ...

  2. spring 读取properties文件--通过注解方式

    问题: 需要通过properties读取页面的所需楼盘的名称.为了以后便于修改. 解决: 可以通过spring的 PropertiesFactoryBean 读取properties属性,就不需要自己 ...

  3. Java-马士兵设计模式学习笔记-工厂模式-模拟Spring读取Properties文件

    一.目标:读取properties文件,获得类名来生成对象 二.类 1.Movable.java public interface Movable { void run(); } 2.Car.java ...

  4. spring 读取properties的两种方法

    一:直接使用context命名空间 <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi= ...

  5. Spring: 读取 .properties 文件地址,json转java对象,el使用java类方法相关 (十三)

    1. 在Java中获取 .properties 文件的路径 (src/main/resources 下) ProjectName |---src/main/java |---src/main/reso ...

  6. Spring读取properties资源文件

    我们知道可以通过读取资源文件流后加载到Properties对象,再使用该对象方法来获取资源文件.现在介绍下利用Spring内置对象来读取资源文件. 系统启动时加载资源文件链路:web.xml --&g ...

  7. spring读取properties和其他配置文件的几种方式

    1.因为spring容器的一些机制,在读取配置文件进行数据库的配置等等是很有必要的,所以我们要考虑配置文件的的读取方式以及各个方式的实用性 2.配置文件的读取方式我这里介绍2种,目的是掌握这2种就可以 ...

  8. java读取properties配置文件方法(一)

    为了修改项目参数方便,需要使用properties配置文件: 首先是需要三个jar包(不同的jar包,读取配置文件的方式会有所不同,这里使用的是2.6版本的jar包) commons configur ...

  9. @Schedule注解中的Cron表达式读取properties的方法

    1.properties文件中增加配置项: datasync.cron=0 */10 * * * ? 2.定时任务类增加PropertySource注解: @PropertySource(" ...

随机推荐

  1. Please ensure that adb is correctly located at……问题解决方案

    启动android模拟器时.有时会报The connection to adb is down, and a severe error has occured.的错误.在网友说在任务管理器上把所有ad ...

  2. hdu 1024(最大和连续子序列增强版)

    题意:最大和连续子序列的增强版,要求从一序列中取出若干段,这些段之间不能交叉,使得和最大并输出. 分析:用dp[i][j]表示前j个数取出i段得到的最大值,那么状态转移方程为dp[i][j]=max( ...

  3. Spring分布式事务实现

    分布式事务是指操作多个数据库之间的事务,spring的org.springframework.transaction.jta.JtaTransactionManager,提供了分布式事务支持.如果使用 ...

  4. Android 中屏幕点击事件的实现

    在Android中如何用代码触发按钮点击事件?我想要触发代码执行按钮点击.实现对于单击按钮事件的模拟,触发单击按钮进入另一个界面. 就是声明一下什么moonlightcheese被声明了:在andro ...

  5. KVO KVC

    @interface FoodData : NSObject { NSString * foodName; float foodPrice; } @end ////////////////////// ...

  6. EF6 Database First (DbContext) - Change Schema at runtime

    Problem:There are two SQL databases (dev and live) with on Azure which has identical table structure ...

  7. linux下mysql数据库的学习

    转载博客:http://freedomljtt.blog.163.com/blog/static/72294949201210145441701/ ubuntu12.04 卸载和安装mysql 卸载m ...

  8. 【九度OJ】题目1096-二分查找

    题目1069:查找学生信息 这篇文章中提到的问题主要是由于调试平台Visual Studio和测试平台Online Judge的一些小差异,造成在Visual Studio中调试通过的代码,在输入OJ ...

  9. 2.2……测试

    概述 黑盒测试: 是以用户的角度,从输入数据与输出数据的对应关系出发进行测试的.   白盒测试: 又称结构测试.透明盒测试.逻辑驱动测试或基于代码的测试.   单元测试: 又称模块测试,是开发者编写的 ...

  10. 第三次作业,GUI设计之最大子序列和

    先吐槽一发!!!学渣表示作业太难了啊!!!!!!做一次作业要用好久好久,要问好多好多大神才能行,虽然确实提高不少,花的时间真是……!!!!! 这次作业费劲心血,希望老师能给个好分数,至少对于学渣来说已 ...