文章目录
一、Druid连接池
1.1 druid.properties文件
druid.driverClassName=com.mysql.cj.jdbc.Driver
druid.url=jdbc:mysql://localhost:3306/mybatis?userUnicode=true&characterEncoding=utf8&useSSL=true&serverTimezone=GMT%2B8
druid.username=root
druid.password=root
1.2 方式一
引入单个
<!--方式一:不建议使用,过时了-->
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:druid.properties"/>
</bean>
<!--druid连接池-->
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
<property name="driverClassName" value="${druid.driverClassName}"/>
<property name="url" value="${druid.url}"/>
<property name="username" value="${druid.username}"/>
<property name="password" value="${druid.password}"/>
</bean>
引入多个
<!-- 引入多个属性文件方法一 -->
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:c3p0.properties</value>
<value>classpath:druid.properties</value>
</list>
</property>
</be