一、创建Java Web Application项目
1、在Web Application项目下创建一个module,自定义名字,在module——src——web——WEB-INF目录下创建lib文件夹,将spring框架所需的jar包放入其中,再全部选中jar包进行添加。
2、在module的src目录下,创建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: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">
</beans>
然后创建好model、dao、impl、service层之后,在xml文件中依次进行数据库连接、创建jdbcTemplate对象来自动注入dataSource、扫描注解、创建dao层对象、创建service对象共5