Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use tk.mybatis Code Generator in springboot

2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article focuses on "how to use tk.mybatis code generator in springboot". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor learn how to use the tk.mybatis code generator in springboot.

Tk.mybatis is a further encapsulation of mybatis, which further encapsulates the addition, deletion, modification and query of a basic single table. The use of springboot has been written before. If you haven't used it, please refer to my previous article, "using PageHelper and tk.mybatis in springboot". This article introduces the use of tk.mybatis code generator.

Pom add plug-in (optional)

After the plug-in is configured. If the IDE tool uses idea, the plug-in can be seen in the maven view on the right

GeneratorConfig.xml configuration 2

This configuration of tk.mybatis supports the loading of properties files compared to the native one, so you no longer have to worry about the difference between the configuration in the project and the configuration of the generator. This is the way it should be. The same variables come from the same place as far as possible. This is also the norm when writing code.

Run plug-in 3

1. If the plug-in is configured, double-click the plug-in [mybatis-generator:generate] in the maven view.

two。 If you do not configure the plug-in, you need to add a maven run command, find [run configurations], and add a maven command as follows

Either way is fine.

Run result 4

Remarks 5

In the generated DictMapper.xml, there is only table structure mapping, and there are no additions, deletions, changes and queries. MyMapper is inherited in DictMapper. At this time, DictMapper already has basic single table operation methods such as additions, deletions, changes and queries. This is the magic of general Mapper.

At this point, I believe you have a deeper understanding of "how to use the tk.mybatis code generator in springboot". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report