ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# 1. idea安装插件 ![](https://img.kancloud.cn/ef/26/ef263f97341fe5063f2ea70d5aee408e_1225x294.png) 分为default和mybatis-plus分组 # 2. 自定义代码模板配置 ![](https://img.kancloud.cn/d7/5d/d75d2f47633d05b3b7fb825251f5203f_1022x662.png) ## 2.1 替换生成代码表名前缀 例如表名 `t_pest_data_ecological`会生成`TPestDataEcologicalController` ![](https://img.kancloud.cn/73/90/739056791c9ce5a5e9d6bf1a57fc9a6c_1505x476.png) 就是从init中拷贝出来的 ![](https://img.kancloud.cn/09/79/0979d2853a2ba929181d89db61c9b334_1267x310.png) ## 2.2 修改代码 ![](https://img.kancloud.cn/c5/15/c515020cdb47c5d0ce33340832511168_1140x526.png) # 3. 生成代码 右键表名 ![](https://img.kancloud.cn/4d/b3/4db3fccfd74f2277c43f96a4df30b637_1079x308.png) ![](https://img.kancloud.cn/b2/ae/b2aeacde613c60bcca403fa96e6cdcd4_973x503.png) # 2. JSON ## 2.1 根据json数据自动生成JavaBean的属性 ![](https://img.kancloud.cn/e1/99/e199a7b41b33b9de07c8c7dfe58e6413_1329x519.png) ![](https://img.kancloud.cn/92/f8/92f88da0cc4e70b4a7a3427d126d981e_1328x579.png) ![](https://img.kancloud.cn/3a/e9/3ae96d8d552bab4df4881d4d7727bf48_596x373.png) ![](https://img.kancloud.cn/3d/5f/3d5fa00a82b13fac36e1257a5758f57b_954x621.png) ``` { "pestName": "落叶松落叶病", "statistics": [ { "monitorYear": 2016, "pestName": "落叶松落叶病", "totalPestArea": 0 }, { "monitorYear": 2017, "pestName": "落叶松落叶病", "totalPestArea": 0 }, { "monitorYear": 2018, "pestName": "落叶松落叶病", "totalPestArea": 0 }, { "monitorYear": 2019, "pestName": "落叶松落叶病", "totalPestArea": 0 }, { "monitorYear": 2020, "pestName": "落叶松落叶病", "totalPestArea": 0 } ] } ``` 生成代码 ~~~ public class Animal { /** * pestName : 落叶松落叶病 * statistics : [{"monitorYear":2016,"pestName":"落叶松落叶病","totalPestArea":0},{"monitorYear":2017,"pestName":"落叶松落叶病","totalPestArea":0},{"monitorYear":2018,"pestName":"落叶松落叶病","totalPestArea":0},{"monitorYear":2019,"pestName":"落叶松落叶病","totalPestArea":0},{"monitorYear":2020,"pestName":"落叶松落叶病","totalPestArea":0}] */ private String pestName; private List<StatisticsBean> statistics; public String getPestName() { return pestName; } public void setPestName(String pestName) { this.pestName = pestName; } public List<StatisticsBean> getStatistics() { return statistics; } public void setStatistics(List<StatisticsBean> statistics) { this.statistics = statistics; } public static class StatisticsBean { /** * monitorYear : 2016 * pestName : 落叶松落叶病 * totalPestArea : 0 */ private int monitorYear; private String pestName; private int totalPestArea; public int getMonitorYear() { return monitorYear; } public void setMonitorYear(int monitorYear) { this.monitorYear = monitorYear; } public String getPestName() { return pestName; } public void setPestName(String pestName) { this.pestName = pestName; } public int getTotalPestArea() { return totalPestArea; } public void setTotalPestArea(int totalPestArea) { this.totalPestArea = totalPestArea; } } } ~~~ ## 2.2 json2java 右键选择 ![](https://img.kancloud.cn/a0/11/a0116362ca1f18febbeabc4930412095_1134x560.png) 复制字符串 ![](https://img.kancloud.cn/43/7f/437f4abcba5835e616a48e22addddeee_1474x653.png) # 3. Codota 极其强大的代码自动补全 **Tabnine** 用于替代Codota,实现代码补全 # 5. 自动生成set方法 **GenerateAllSetter**,一键调用一个对象的所有set方法并且赋予默认值 在对象字段多的时候非常方便,在做项目时,每层都有各自的实体对象需要相互转换,但是考虑BeanUtil.copyProperties()等这些工具的弊端,有些地方就需要手动的赋值时,有这个插件就会很方便,创建完对象后在变量名上面按Alt+Enter就会出来 generate all setter选项。 ![](https://img.kancloud.cn/ab/9c/ab9c66a7a30a1c85ce3de3666177efb5_490x128.png) # 6. 驼峰 idea菜单栏-file-settings-plugins-在marketplace搜索“CamelCase”-点击安装 ![](https://img.kancloud.cn/92/65/926586076037b4e3be8cd38732f96023_760x210.png) idea菜单栏-file-settings-editor-camel\_case,选中自己常用的格式点击保存 ![](https://img.kancloud.cn/95/d1/95d18e6525ab663046fda4230b3da066_730x518.png) 重新打开idea,选中内容,使用快捷键:shit+alt+u,就会转换 # 7. Alibaba Java Coding Guidelines 首先要推荐的是和《手册》配套的[阿里巴巴 Java代码规范插件](https://link.zhihu.com/?target=https%3A//plugins.jetbrains.com/plugin/10046-alibaba-java-coding-guidelines)。 安装该插件后,代码超过 80 行、手动创建线程池等,这些和《手册》中的规约不符时,IDEA中会给出警告提示。 建议大家一定一定一定要安装该插件,它会帮助你检查出很多隐患,督促你写更规范的代码。 # myabtis # MyBatisCodeHelperPro ​(Marketplace Edition)​ 下载适用版本 https://plugins.jetbrains.com/plugin/14522-mybatiscodehelperpro-marketplace-edition-/versions # 8. aiXcoder 智能补全代码