目录

Spring整合Mybatis

Spring整合Service层


Spring整合Mybatis

新建spring-dao.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/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/contexthttps://www.springframework.org/schema/context/spring-context.xsd"><!-- 配置整合mybatis --><!-- 1.关联数据库文件 --><context:property-placeholder location="classpath:database.properties"/><!-- 2.数据库连接池 --><!--数据库连接池dbcp 半自动化操作 不能自动连接c3p0 自动化操作(自动的加载配置文件 并且设置到对象里面)--><bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"><!-- 配置连接池属性 --><property name="driverClass" value="${jdbc.driver}"/><property name="jdbcUrl" value="${jdbc.url}"/><property name="user" value="${jdbc.username}"/><property name="password" value="${jdbc.password}"/><!-- c3p0连接池的私有属性 --><property name="maxPoolSize" value="30"/><property name="minPoolSize" value="10"/><!-- 关闭连接后不自动commit --><property name="autoCommitOnClose" value="false"/><!-- 获取连接超时时间 --><property name="checkoutTimeout" value="10000"/><!-- 当获取连接失败重试次数 --><property name="acquireRetryAttempts" value="2"/></bean><!-- 3.配置SqlSessionFactory对象 --><bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"><!-- 注入数据库连接池 --><property name="dataSource" ref="dataSource"/><!-- 配置MyBaties全局配置文件:mybatis-config.xml --><property name="configLocation" value="classpath:mybatis-config.xml"/></bean><!-- 4.配置扫描Dao接口包,动态实现Dao接口注入到spring容器中 --><!--解释 :https://www.cnblogs.com/jpfss/p/7799806.html--><bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"><!-- 注入sqlSessionFactory --><property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/><!-- 给出需要扫描Dao接口包 --><property name="basePackage" value="com.lt.dao"/></bean></beans>

Spring整合Service层

新建spring-service.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/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context.xsd"><!-- 扫描service相关的bean --><context:component-scan base-package="com.lt.service" /><!--BookServiceImpl注入到IOC容器中--><bean id="BookServiceImpl" class="com.lt.service.BookServiceImpl"><property name="bookMapper" ref="bookMapper"/></bean><!-- 配置事务管理器 --><bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"><!-- 注入数据库连接池 --><property name="dataSource" ref="dataSource" /></bean></beans>

SSM整合第二步之Spring相关推荐

  1. SSM整合(springMVC+spring+Mybatis)

    目录 前言 (一)三个框架的应用 SpringMVC Spring Mybatis (二)整合步骤 包结构 1.pom..xml导入依赖 2.配置web.xml文件 3.创建springmvc.xml ...

  2. SSM学习——SSM整合案例(Spring+SpringMVC+Mybatis)(13)

    这里写目录标题 要求 Spirng整合Mybatis Spirng整合SpringMVC 表与实体类的创建 创建层级 Dao层 Service层 controller层 接口测试 业务层`servic ...

  3. SSM 整合 4:Spring IoC 容器基于的两个重要接口 BeanFactory 和 ApplicationContext

    文章目录 前言 一.BeanFactory 接口 1.1.加载 Spring 配置文件创建 BeanFactory 接口实例 1.2.开发中的运用以及使用说明 二.ApplicationContext ...

  4. SSM整合框架搭建(适合新手)

    SSM整合(SpringMvc+Spring+Mybatis) 首先创建一个Dynamic Web Project(JavaWeb动态工程) 创建一个xxx.xxx.xxx.controller包用来 ...

  5. [转]SSM框架——详细整合教程(Spring+SpringMVC+MyBatis)

    使用SSM(spring.SpringMVC和Mybatis)已经有三个多月了,项目在技术上已经没有什么难点了,基于现有的技术就可以实现想要的功能,当然肯定有很多可以改进的地方.之前没有记录SSM整合 ...

  6. SSM整合(2): spring 与 mybatis 整合

    在进行完spring与springmvc整合之后, 继续 spring与mybatis的整合. 既然是操作数据库, 那必然不能缺少了连接属性 一. db.properties jdbc.driver= ...

  7. java框架ssm整合_SSM三大框架整合详细教程(Spring+SpringMVC+MyBatis)

    使用 SSM ( Spring . SpringMVC 和 Mybatis )已经有三个多月了,项目在技术上已经没有什么难点了,基于现有的技术就可以实现想要的功能,当然肯定有很多可以改进的地方.之前没 ...

  8. Spring ---- ssm整合

    文章目录 SSM(spring+springMVC+Mybatis)整合流程简介 项目基础结构搭建 spring 整合mybatis 创建MyBatis映射文件 创建Spring配置文件.整合Myba ...

  9. ssm如何支持热部署_最新Spring Boot实战文档推荐:项目搭建+配置+SSM整合

    在Spring Boot项目中,正常来说是不存在XML配置,这是因为Spring Boot不推荐使用XML,注意,排不支持,Spring Boot推荐开发者使用Java配置来搭建框架, Spring ...

最新文章

  1. 云计算将成为金融服务业的主流技术
  2. C# - 委托中的逆变
  3. 019_MySQL正则表达式
  4. IntelliJ IDEA 15快捷键大全
  5. bigdecimal判断等于0_shell 脚本中if判断的条件总结
  6. 程序员的自我修养(2)——计算机网络
  7. 西安市2008驾照理论考试题
  8. 输入和用户界面——总结
  9. 016.OpenStack及云计算(面试)常见问题
  10. svn 使用TortoiseSVN server搭建本地SVN服务器
  11. node npm cnpm 全局安装淘宝NPM 镜像
  12. 纯小白使用ffmpeg提取avi视频为MP3
  13. 令你的网站获得任意Google PR值的方法!
  14. 计算机使人孤独英语作文,有关孤独的英语作文4篇
  15. fflush(stdout)和fflush(stdin)
  16. 微信小程序:隐藏和显示功能
  17. h5公众号分享朋友、朋友圈
  18. 微信小程序两种跳转页面的方法
  19. cl.clcl.news/index.php,公布一些后门网址
  20. 逆向教程2 某信营业厅

热门文章

  1. lda主题演化与热度python实现
  2. 游戏建模常用软件介绍,次世代建模全流程解析
  3. 【调剂】河南理工大学2023年硕士研究生调剂信息公布
  4. 计算机专业爱玩游戏的笔记本,玩游戏不卡的笔记本电脑有哪些
  5. python 发微信 自动登录_用python自动给微信好友发消息
  6. 计算最长公共子序列LCS(Python实现)
  7. iphone6无3g显示无服务器,iPhone 6网络实测:移动联通无压力/电信泪奔三条街
  8. sap税码配置_关于SAP税的配置
  9. 轻松胜任在Java中处理Excel表格
  10. 工具篇-旧版火狐浏览器+旧版插件hackbar