How to integrate TkMyBatis and PageHelper in Spring Boot
This article is about how to integrate TkMyBatis and PageHelper in Spring Boot. The editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article.
1. Idea installs the code generator
2. Refer to the link above for offline installation.
3. Introduce the mapper-spring-boot-starter dependency into the pom.xm file, which automatically introduces the MyBaits dependency.
Tk.mybatis mapper-spring-boot-starter 2.1.5
4 、 application.yml
Mybatis: # path for storing entity classes type-aliases-package: cn.itchao.domain mapper-locations: classpath:mapper/*.xml
5. Create a common parent interface
The main function is to let the interface of the DAO layer inherit the interface in order to achieve the purpose of using tk.mybatis. Be careful not to let springboot scan the interface.
Package tk.mybatis.mapper;import tk.mybatis.mapper.common.Mapper;import tk.mybatis.mapper.common.MySqlMapper;/** * pay special attention to the fact that the interface cannot be scanned, otherwise there will be errors * / public interface MyMapper extends Mapper, MySqlMapper {}
6. Integrate paging plug-ins
Introducing pagehelper-spring-boot-starter dependencies into pom.xml files
Com.github.pagehelper pagehelper-spring-boot-starter 1.2.12 above is how to integrate TkMyBatis and PageHelper in Spring Boot. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.