spring中的PropertyPlaceholderConfigurer访问properties文件配置
来源:互联网 发布:js 表单如何拼接字符串 编辑:程序博客网 时间:2024/06/04 21:06
Spring的框架中提供了一个类: org.springframework.beans.factory.config.PropertyPlaceholderConfigurer。这个类,可以将一些经常需要改动的配置如用户名密码等,移至.properties文件中,而.properties文件可以作为客户根据需求,自定义一些相关的参数。
来看一个spring配置C3P0连接池的例子:
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:p="http://www.springframework.org/schema/p" 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/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd"> <bean id="config" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <!--单个properties文件采用以下写法--> <property name="location"> <value>classpath:jdbc.properties</value> </property> <!--多个properties文件采用以下写法--> <property name="locations"> <list> <value>classpath:jdbc.properties</value> <value>classpath:xxx.properties</value><value>classpath:xxx.properties</value> </list> </property> </bean> <!-- 配置c3p0连接池 --> <bean id="comboPooledDataSourceID" class="com.mchange.v2.c3p0.ComboPooledDataSource"> <property name="driverClass" value="${driverClassName}"/> <property name="jdbcUrl" value="${url}"/> <property name="user" value="${username}"/> <property name="password" value="${password}"/> </bean> </beans>
jdbc.properties
driverClassName=com.mysql.jdbc.Driverurl=jdbc\:mysql\://localhost\:3306/testusername=rootpassword=root
0 0
- spring中的PropertyPlaceholderConfigurer访问properties文件配置
- Spring中配置和读取多个Properties文件-- PropertyPlaceholderConfigurer
- 使用spring的PropertyPlaceholderConfigurer加密properties文件中的属性
- Spring注入Properties文件中的配置
- Spring PropertyPlaceholderConfigurer解析Java Properties属性文件值
- Spring的PropertyPlaceholderConfigurer应用与集成项目properties文件管理
- springMVC框架中多个配置文件使用PropertyPlaceholderConfigurer读取配置properties文件
- Spring PropertyPlaceholderConfigurer初始化properties配置文件
- spring的 PropertyPlaceholderConfigurer配置
- Spring配置之PropertyPlaceholderConfigurer
- Spring 配置之 PropertyPlaceholderConfigurer
- spring中的PropertyPlaceholderConfigurer
- spring中的PropertyPlaceholderConfigurer类
- Spring - XML中的PropertyPlaceholderConfigurer
- Spring 依赖注入:自动注入properties文件中的配置
- Spring 依赖注入:自动注入properties文件中的配置
- Spring读取properties:PropertiesFactoryBean和PropertyPlaceholderConfigurer
- spring xml配置properties文件
- SEO快速排名算法独家揭秘
- eclipse工程导入androidstudio之后,在androidstudio中修改app包名
- 字典树的应用
- 分组背包问题Matlab实现——之基本背包变形
- ADT新建项目出现appcompat_v7包,删除后styles报错
- spring中的PropertyPlaceholderConfigurer访问properties文件配置
- ORA-28000 用户被锁定
- 工厂模式三 抽象工厂模式
- 51nod - 1136 欧拉函数(欧拉函数)
- sql server 当中Go的用法
- Android数据存储之GreenDao 3.0 详解
- 最近在使用MediaRecorder录制视频的时候遇到crash
- linux下源码安装R-3.1.2.tar.gz和RStudio开发工具
- Android Studio 导入包设置