在项目的src下有一个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"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
<!-- 扫描类包, 将标注Spring注解的类自动转化为Bean, 同时完成Bean的注入 -->
<context:component-scan base-package="com.baobaotao.dao"/>
<!-- 定义一个使用DBCP实现的数据源 -->
<bean id="dataSource" class="org.apache.common