改造分层设计
Controller + Service + DAO
Controller --> Service -> ServiceImpl -> DAO -> sprintboot.application.properties -> Mybatis xml file -> namespace 指定的sql
DAO 层只负责数据库增删改查
具体业务逻辑 在ServiceImpl 层以及Mybatis xml sql 里定义
注意:resources/mapper 目录下的UserDao.xml 文件名需要在 application.properties 需要配置 mybatis.mapper-locations=classpath:mapper/*Dao.xml
否则会有 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)问题
最终项目结构如下:
本系列文章 参考学习作者 软件测试架构师俱乐部 https://mp.weixin.qq.com/s/9lcUIvDS3qNqiFnZqE4rRA