1、管理第三方资源
DruidDataSource
ComboPooledDataSource
2、加载properties文件
开启context命名空间
<?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:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
使用context空间加载properties文件
<context:property-placeholder location="jdbc.properties"/>
使用属性占位符${}读取properties文件中的属性
<bean class="com.alibaba.druid.pool.DruidDataSource">
<property name="driverClassName" value="${jdbc.driver}"/>
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
</bean>
</beans>
<context:property-placeholder location="classpath:*.properties" system-properties-mode="NEVER"/>//仅从当前工程读取;不加载系统属性
location="classpath*:*.properties" 从类路径或jar包中搜索并加载properties文件