spring中PropertyPlaceholderConfigurer的使用,引入外部资源文件
来源:互联网 发布:node.js go 编辑:程序博客网 时间:2024/05/18 13:44
PropertyPlaceholderConfigurer的使用
在开发web端应用时,我们一般都是把数据库那部分资源写在一个***.properties文件中,然后在application中通过${}获取相应的值。
1.db.properties
db.driver=com.mysql.jdbc.Driver
db.url=jdbc:mysql://localhost:3306/study?characterEncoding=UTF-8&useUnicode=true
db.username=root
db.password=root
db.url=jdbc:mysql://localhost:3306/study?characterEncoding=UTF-8&useUnicode=true
db.username=root
db.password=root
2.applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"
default-lazy-init="false">
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"
default-lazy-init="false">
<bean id="placeholderConfig"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:db.properties</value>
</list>
</property>
</bean>
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:db.properties</value>
</list>
</property>
</bean>
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName">
<value>${db.driver}</value>
<value>${db.driver}</value>
</property>
<property name="url">
<value>${db.url}</value>
</property>
<property name="username">
<value>${db.username}</value>
</property>
<property name="password">
<value>${db.password}</value>
</property>
</bean>
<property name="url">
<value>${db.url}</value>
</property>
<property name="username">
<value>${db.username}</value>
</property>
<property name="password">
<value>${db.password}</value>
</property>
</bean>
阅读全文
1 0
- spring中PropertyPlaceholderConfigurer的使用,引入外部资源文件
- spring中使用外部属性文件(关于PropertyPlaceholderConfigurer)
- Spring 中 PropertyPlaceholderConfigurer 的使用
- Spring中PropertyPlaceholderConfigurer的使用
- Spring中PropertyPlaceholderConfigurer的使用
- Spring中PropertyPlaceholderConfigurer的使用
- Spring中PropertyPlaceholderConfigurer的使用
- Spring中PropertyPlaceholderConfigurer的使用
- Spring中PropertyPlaceholderConfigurer的使用
- spring中PropertyPlaceholderConfigurer的使用
- Spring中PropertyPlaceholderConfigurer的使用
- Spring中PropertyPlaceholderConfigurer的使用(一)
- Spring中PropertyPlaceholderConfigurer的使用(二)
- Spring中PropertyPlaceholderConfigurer的使用(一)
- Spring中PropertyPlaceholderConfigurer的使用介绍
- Spring中PropertyPlaceholderConfigurer的使用(一)
- spring中PropertyPlaceholderConfigurer和PropertyOverrideConfigurer的使用
- Spring PropertyPlaceholderConfigurer的使用
- adapter中的getView方法,不在没有选择的情况下,不要用for循环
- ARM指令的寻址方式
- 拉格朗日乘数法
- C++ 文件操作
- UVALive
- spring中PropertyPlaceholderConfigurer的使用,引入外部资源文件
- 自定义控件之绘图篇:Paint之ColorMatrix与滤镜效果
- git clone 提高速度
- jmeter: JDBC Request配置oracle连接
- JAVA中int转String类型有三种方法
- 从UGUI源码中想到的UI动态”挖洞”效果的实现(蒙版过滤)
- Android APK反编译就这么简单 详解(附图)
- matplotlib模块数据可视化-设置次坐标轴
- js实现下雪情景