微信二维码
微博二维码
qq号二维码

Springboot中引入Mybatis

王伟平 2020.01.16 1161人浏览
Springboot中引入Mybatis

首先在pom.xml中引入mybatis的技术依赖和MySQL的链接依赖  

Springboot中引入Mybatis

然后点击com.happy.item中新建controller包再新建一个controller类ItemController



com.happy.item中新建一个dao层

Springboot中引入Mybatis

dao中新建一个接口类ItemDao

Springboot中引入Mybatis

以及新建一个mapper包,在包内新建一个xml

Springboot中引入Mybatis

删除选中的部分

Springboot中引入Mybatis

新建一个service层里面新建一个接口类和一个实现类

Springboot中引入Mybatis

然后在application中写上链接语句

Springboot中引入Mybatis

在pom中插入工程在运行/打包时能够扫描到dao层的xml文件

Springboot中引入Mybatis

在service的实现类中与接口类链接

Springboot中引入Mybatis

dao层中的接口类与mapper链接与全查询sql语句

Springboot中引入Mybatis

Springboot中引入Mybatis

service中实现类调用dao层中的方法

Springboot中引入Mybatis

controller中调用service接口类中的方法

Springboot中引入Mybatis

实现

Springboot中引入Mybatis

分享到:
天津UI设计培训-CleanPNG免抠素材网站
  • 2020.11.30
  • "天津IT培训适应经济新常态:中日职场比较 - 探索工作时长减少、生活质量提升的程序员"
  • 2024.04.23