栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

图书管理系统(二)整合 SSM

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

图书管理系统(二)整合 SSM

[](()2.2 配置 SqlSessionFactory 对象(MyBatis)

在 src/main/resources 下创建 MyBatis 配置文件 mybatis-config.xml,然后再在 spring-dao.xml 中配置 SqlSessionFactory;

[](()2.3 组件扫描

[](()3. service 层整合


在 src/main/resources/spring 下新建 spring-service.xml,用于整合 service 层,主要做的事情是有如下几点:

  1. 扫描 service 包下所有带有注解 @Service 的类

  2. 配置事务管理器

  3. 配置基于注解的声明式事务

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 层的整合需要做的事情主要有如下几点:

  1. 开启 Spring MVC 的注解模式,毕竟现在大多都是基于注解开发了

  2. 对静态资源如图片、样式和脚本等进行处理

  3. 配置视图解析器;

  4. 扫描 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


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/855343.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号