所谓管理数据源,在我理解似乎也就是连接数据库操作,即如何使用bean连接数据库,
1.先来看一下第一种连接方式,即通过properties文件进行连接
jdbc.properties文件内容
jdbc.driver=com.mysql.cj.jdbc.Driver jdbc.url=jdbc:mysql://localhost:3306/ssm?serverTime=UTC jdbc.username=root jdbc.password=123456
接下来我们来看一下配置文件中的内容,配置文件spring-datasource.xml,通过
<context:property-placeholder></context:property-placeholder>引入写好的properties文件
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
xmlns:p="http://www.springframework.org/schema/p"
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