2021-08-19spring整合mybatis

模块目录如下

一、mybatis-spring.properties

jdbc.driver=com.mysql.jdbc.Driver

jdbc.url=jdbc:mysql://127.0.0.1:3306/spring_mybatis?useUnicode=true&serverTimezone=PRC&characterEncoding=utf-8&useSSL=false

jdbc.username=root

jdbc.password=root

二、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:context="http://www.springframework.org/schema/context"

      xsi:schemaLocation="http://www.springframework.org/schema/beans

https://www.springfram  ework.org/schema/beans/spring-beans.xsd

http://www.springframework.org/schema/context

        https://www.springframework.org/schema/context/spring-context.xsd">

三、AccoutMapper.xml

注意:AccoutMapper.xml要和AccountMapper接口在同一个目录下

但是spring接管了mybatis,需要将AccountMapper.xml文件和applicationContext都放在resources目录下

四、AccountMapper接口

五、AccountService接口

六、AccountServiceImpl

七、测试

测试前需要在ApplicationContext.xm文件中添加

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。