spring中context:property-placeholder
发现网上对于这个标签的解释过于复杂,这里从实用性角度简短的进行说明。
首先,它是spring3中提供的标签。
只需要在spring的配置文件里添加一句:
<context:property-placeholder location="classpath:jdbc.properties"/>
这里location值为参数配置文件的位置,参数配置文件通常放在src目录下
jdbc配置文件:
test.jdbc.driverClassName=com.mysql.jdbc.Driver
test.jdbc.url=jdbc:mysql://localhost:3306/test
test.jdbc.username=root
test.jdbc.password=root
这样一来就可以为spring配置的bean的属性设置值了
在配置文件里这么定义bean:
<bean id="testDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${test.jdbc.driverClassName}"/>
<property name="url" value="${test.jdbc.url}"/>
<property name="username" value="${test.jdbc.username}"/>
<property name="password" value="${test.jdbc.password}"/>
</bean>
甚至可以将${ }这种形式的变量用在spring提供的注解当中,为注解的属性提供值
spring中context:property-placeholder的更多相关文章
- spring中context:property-placeholder/元素 转载
spring中context:property-placeholder/元素 转载 1.有些参数在某些阶段中是常量 比如 :a.在开发阶段我们连接数据库时的连接url,username,passwo ...
- spring中 context:property-placeholder 导入多个独立的 .properties配置文件
spring中 context:property-placeholder 导入多个独立的 .properties配置文件? Spring容器采用反射扫描的发现机制,在探测到Spring容器中有一个 o ...
- Spring中<context:annotation-config/>
最近在研究Spring中<context:annotation-config/>配置的作用,现记录如下: <context:annotation-config/>的作用是向Sp ...
- Spring中<context:annotation-config/>的作用
spring中<context:annotation-config/>配置的作用,现记录如下: <context:annotation-config/>的作用是向Spring容 ...
- Spring中 <context:property-placeholder 的使用与解析 .properties 配置文件的加载
转: Spring中property-placeholder的使用与解析 Spring中property-placeholder的使用与解析 我们在基于spring开发应用的时候,一般都会将数据库的配 ...
- spring中context:property-placeholder/元素
1.有些参数在某些阶段中是常量 比如 :a.在开发阶段我们连接数据库时的连接url,username,password,driverClass等 b.分布式应用中client端访问server端所用的 ...
- Spring 中context.start作用
我们经常会看到 如下代码 ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(configPath. ...
- 关于spring中<context:component-scan base-package="" />写法
1.通配符形式<context:component-scan base-package="com.*" /> 2.全路径 <context:component-s ...
- spring中<context:property-placeholder/>一个坑
<context:property-placeholder location="classpath:db.properties" ></context:prope ...
随机推荐
- 使用SimpleDateFormat解析日期得到年份不正确的结果
今天写项目的时候发现日期解析结果不对,很纳闷,从控制台中看传过来的数据是对的,但解析得到数据就是错的,如下图 最终查资料发现是格式上的错误,年份的YYYY应该改成yyyy,之后就正常了. 以下是正确格 ...
- js中String 转化为 Date
<script> var s=["2008-8-1","2009/9/2","10/3/2010"]; for(var i=0; ...
- 微信小程序引用iconfont图标字体解决方案;
1)首先,登录阿里巴巴iconfont.cn 2)新建项目 3)点击icon收藏 4)加入到test项目中 5)下载到本地解压 6)生成代码 7)复制iconfont.css到xxx.wx ...
- 【Nginx一】Nginx服务器搭建
Nginx服务器搭建 Nginx服务器搭建 下载Nginx源码包 安装Nginx 解压Nginx安装包 安装Nginx依赖 启动Nginx 下载Nginx源码包 官网下载地址 命令:wget http ...
- 工作中使用的linux命令汇总
ln -s /usr/local/tomcat/ ./tomcat 创建软连接到/usr/local/tomcat tar -zxvf apache-kylin-2.4.0-bin-hbase1 ...
- FPGA算法学习(1) -- Cordic(圆周系统之旋转模式)
三角函数的计算是个复杂的主题,有计算机之前,人们通常通过查找三角函数表来计算任意角度的三角函数的值.这种表格在人们刚刚产生三角函数的概念的时候就已经有了,它们通常是通过从已知值(比如sin(π/2)= ...
- 46-Identity MVC:登录逻辑实现
1- Login.cshtml <h3>Login</h3> @model MvcCookieAuthSample.ViewModel.LoginViewModel <d ...
- WPF中,如何将绑定源设置到单件实例
原文:WPF中,如何将绑定源设置到单件实例 WPF中,如何将绑定源设置到单件实例 周银辉 大概两个月前,曾有位朋友问我:如 ...
- Android开发——View动画、帧动画和属性动画详解
0. 前言 Android动画是面试的时候经常被问到的话题.我们都知道Android动画分为三类:View动画.帧动画和属性动画. 先对这三种动画做一个概述: View动画是一种渐进式动画,通过图 ...
- PS作业