当前位置:网站首页>Code generator
Code generator
2022-07-29 01:30:00 【Bai Xiaoyun】
Code generator
According to the field name of the database , Generate code template
public static void main(String[] args) {
//1. Get the object of the code generator
AutoGenerator autoGenerator = new AutoGenerator();
// Set database related configuration
DataSourceConfig dataSource = new DataSourceConfig();
dataSource.setDriverName("com.mysql.cj.jdbc.Driver");
dataSource.setUrl("jdbc:mysql://localhost:3306/mybatisplus_db?serverTimezone=UTC");
dataSource.setUsername("root");
dataSource.setPassword("20020630");
autoGenerator.setDataSource(dataSource);
// Set global configuration
GlobalConfig globalConfig = new GlobalConfig();
globalConfig.setOutputDir(System.getProperty("user.dir")+"/mybatispluse01/src/main/java/com"); // Set code generation location
globalConfig.setOpen(true); // Set whether to open the directory where the generated code is located after generation
globalConfig.setAuthor(" Black horse programmer "); // Set the author
globalConfig.setFileOverride(true); // Set whether to overwrite the original generated file
globalConfig.setMapperName("%sDao"); // Set the data layer interface name ,%s As a placeholder , Refers to the module name
globalConfig.setIdType(IdType.ASSIGN_ID); // Set up Id Generation strategy
autoGenerator.setGlobalConfig(globalConfig);
// Set package name related configuration
PackageConfig packageInfo = new PackageConfig();
packageInfo.setParent("com.aaa"); // Set the generated package name , Does not conflict with the location of the code , The two superimpose to form a complete path
packageInfo.setEntity("domain"); // Set entity class package name
packageInfo.setMapper("dao"); // Set the data layer package name
autoGenerator.setPackageInfo(packageInfo);
// Policy settings
StrategyConfig strategyConfig = new StrategyConfig();
strategyConfig.setInclude("tbl_user"); // Set the name of the table currently participating in the generation , Parameters are variable parameters
strategyConfig.setTablePrefix("tbl_"); // Set the prefix name of the database table , Module name = Database table name - Prefix for example : User = tbl_user - tbl_
strategyConfig.setRestControllerStyle(true); // Set whether to enable Rest style
strategyConfig.setVersionFieldName("version"); // Set optimistic lock field name
strategyConfig.setLogicDeleteFieldName("deleted"); // Set the logical deletion field name
strategyConfig.setEntityLombokModel(true); // Set whether to enable lombok
autoGenerator.setStrategy(strategyConfig);
//2. Perform the build operation
autoGenerator.execute();
}
}
边栏推荐
- Regular checksum time formatting
- C语言300行代码实现扫雷(可展开+可标记+可更改困难级别)
- [ManageEngine] help Harbin Engineering University realize integrated monitoring and management of network traffic
- Error installing mysqlclient module on MAC system
- 【HCIP】MPLS 基础
- Summary of process and thread knowledge points 1
- Transfer: cognitive subculture
- uniapp createSelectorQuery(). Select get returns null error
- ValueError: Colors must be aRGB hex values
- IT硬件故障的主要原因和预防的最佳实践
猜你喜欢
![[leetcode sliding window problem]](/img/84/566d3805e52c358603694cdec69a13.png)
[leetcode sliding window problem]

SQL injection of DVWA

括号匹配的检验

Introduction to FLV documents

Third party login process of flask Weibo

教你一文解决 js 数字精度丢失问题

了解各种路径

【mysql】多指标历史累计去重问题
![[SQL's 18 dragon subduing palms] 01 - Kang long regrets: introductory 10 questions](/img/db/d0255d7036f7003d380c8888fed88b.png)
[SQL's 18 dragon subduing palms] 01 - Kang long regrets: introductory 10 questions

Self-attention neural architecture search for semantic image segmentation
随机推荐
表达式求值
北京护照西班牙语翻译推荐
Intel带你初识视觉识别--OpenVINO
20220728-不纯为数字的字符串排序
代码生成器
Canal实时解析mysql binlog数据实战
SDRAM Controller Design (two design methods of digital controller)
RHCE命令练习(二)
【Leetcode-滑动窗口问题】
API stability guarantee of Prometheus
Hilbert transform and instantaneous frequency
Cookies and sessions
Canal real-time parsing MySQL binlog data practice
一篇万字博文带你入坑爬虫这条不归路 【万字图文】
Flink SQL Hudi 实战
全新升级:获得淘宝商品详情“高级版” API
测试/开发程序员靠技术渡过中年危机?提升自己本身的价值......
[ManageEngine] help Harbin Engineering University realize integrated monitoring and management of network traffic
【ManageEngine】助力哈尔滨工程大学实现网络流量一体化监控管理
How to smoothly go online after MySQL table splitting?