模块目录如下
一、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文件中添加