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 mybatis plus Code Generator

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

Share

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

This article mainly explains the "use of mybatis plus code generator", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "the use of mybatis plus code generator" bar!

Mybatis plus usage

Org.springframework.boot spring-boot-starter-parent 2.1.6.RELEASE org.springframework.boot spring-boot-starter org.springframework.boot spring-boot-starter-test test org.projectlombok lombok true com.baomidou mybatis-plus-boot-starter 3.1.2 Com.h3database H3 runtime public static void main (String [] args) {/ / Code Generator AutoGenerator mpg = new AutoGenerator () / / Global configuration GlobalConfig gc = new GlobalConfig (); gc.setOutputDir ("D:\\ Develop"); gc.setAuthor ("ivan"); gc.setOpen (false); gc.setFileOverride (true); gc.setBaseResultMap (true); gc.setBaseColumnList (true); / / gc.setSwagger2 (true); entity attribute Swagger2 annotation mpg.setGlobalConfig (gc) / / data source configuration DataSourceConfig dsc = new DataSourceConfig (); dsc.setUrl ("jdbc:mysql://localhost:3306/ivan?useUnicode=true&useSSL=false&characterEncoding=utf8"); / / dsc.setSchemaName ("public"); dsc.setDriverName ("com.mysql.jdbc.Driver"); dsc.setUsername ("root"); dsc.setPassword ("password"); mpg.setDataSource (dsc) / / package configuration PackageConfig pc = new PackageConfig (); pc.setParent ("com.leyou"); mpg.setPackageInfo (pc); / / Custom configuration InjectionConfig cfg = new InjectionConfig () {@ Override public void initMap () {/ / to do nothing}} / / mpg.setCfg (cfg) must be set; / / Policy configuration StrategyConfig strategy = new StrategyConfig (); strategy.setNaming (NamingStrategy.underline_to_camel); strategy.setColumnNaming (NamingStrategy.underline_to_camel); / / strategy.setSuperEntityClass ("com.baomidou.ant.common.BaseEntity"); strategy.setEntityLombokModel (true) Strategy.setRestControllerStyle (true); / / Public parent class / / strategy.setSuperControllerClass ("com.baomidou.ant.common.BaseController"); / / Public field written in the parent class / / strategy.setSuperEntityColumns ("id"); strategy.setInclude (new String [] {"tb_category"}); / / strategy.setControllerMappingHyphenStyle (true); strategy.setTablePrefix ("tb_") Mpg.setStrategy (strategy); mpg.execute ();} Thank you for your reading, this is the content of "how to use mybatis plus Code Generator". After the study of this article, I believe you have a deeper understanding of the use of mybatis plus code generator, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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