在 src/main/resources 下创建 MyBatis 配置文件 mybatis-config.xml,然后再在 spring-dao.xml 中配置 SqlSessionFactory;
[](()3. service 层整合
在 src/main/resources/spring 下新建 spring-service.xml,用于整合 service 层,主要做的事情是有如下几点:
-
扫描 service 包下所有带有注解 @Service 的类
-
配置事务管理器
-
配置基于注解的声明式事务
xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xmlns:context=“http://www.springframework.org/schema/context” xmlns:tx=“http://www.springframework.org/schema/tx” 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 http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"> class=“org.springframework.jdbc.datasource.DataSourceTransactionManager”> [](()4. controller 层整合 既然已经整合了 dao 和 service 层,那怎么能少下 controller 层呢。在 src/main/resources/spring 下新建 spring-service.xml ,controller 层的整合需要做的事情主要有如下几点: 开启 Spring MVC 的注解模式,毕竟现在大多都是基于注解开发了 对静态资源如图片、样式和脚本等进行处理 配置视图解析器; 扫描 controller 层 xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xmlns:context=“http://www.springframework.org/schema/context” xmlns:mvc=“http://www.springframework.org/schema/mvc” xsi:schemaLocation=“http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd”> mvc:annotation-driven/ mvc:default-servlet-handler/ [](()5. 配置 web.xml



