Spring配置文件中使用PropertyPlaceholderConfigurer配置获取jdbc的配置信息
2013-01-09 17:31
881 查看
Spring中常用${名称}获取另外的.properties文件配置的信息,可以使用PropertyPlaceholderConfigurer把.properties配置文件导入。
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>classpath:jdbc.properties </value> </list> </property> </bean> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="${jdbc.driverClassName}" /> <property name="url" value="${jdbc.url}" /> <property name="username" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> </bean> </beans>
相关文章推荐
- Spring PropertyPlaceholderConfigurer Usage - 使用系统变量替换spring配置文件中的变量
- Spring PropertyPlaceholderConfigurer Usage - 使用系统变量替换spring配置文件中的变量
- 【转】spring管理属性配置文件properties——使用PropertiesFactoryBean|spring管理属性配置文件properties——使用PropertyPlaceholderConfigurer
- Spring配置文件中jdbc:initialize-database标签应用以及PropertyPlaceholderConfigurer配置的应用
- Spring PropertyPlaceholderConfigurer Usage - 使用系统变量替换spring配置文件中的变量
- Spring中使用 PropertyPlaceholderConfigurer 替换xml配置文件中的Bean配置项
- spring配置:context:property-placeholder 读取配置文件信息 在配置文件中使用el表达式填充值
- spring 配置文件 获取变量(PropertyPlaceholderConfigurer)
- spring_使用占位符连接数据库_PropertyPlaceholderConfigurer_DataSource配置创建获取
- spring 不同 配置文件中的占位符 无法获取 使用 context:property-placeholder
- PropertyPlaceholderConfigurer的用法(使用spring提供的类读取数据库配置信息.properties)
- spring管理属性配置文件properties——使用PropertyPlaceholderConfigurer
- spring使用PropertyPlaceholderConfigurer扩展来满足不同环境的参数配置
- spring使用多个PropertyPlaceholderConfigurer的配置
- PropertyPlaceholderConfigurer在spring获取属性文件
- 关于 Spring 中使用 context:property-placeholder 属性占位符设置配置文件
- spring使用多个PropertyPlaceholderConfigurer的配置
- context:property-placeholder,spring配置文件加载属性信息
- spring中的PropertyPlaceholderConfigurer访问properties文件配置
- spring使用PropertyPlaceholderConfigurer扩展来满足不同环境的参数配置