IDEA代码生成Generate

一、生成set/get方法

当我们在创建实体的时候,难免要生成实体属性的set和get方法,那么此时我们可以有两种方法生成,一种是将光标防止需要生成set和get方法的属性值上,然后按“ALT + ENTER”键,在弹出的栏位中选择”Create getter and setter for ***“,一个属性值一个属性值的生成get和set方法。另一种是按“ALT + INSERT”键,打开Generate弹框,在Generate弹框中选择“Getter and Setter”即可打开get和set方法生成窗口,在窗口中选择需要生成的属性值,单击OK即可。

Generate窗口:

get和set方法生成窗口:

二、生成构造函数

按“ALT + INSERT”键,打开Generate弹框,在Generate弹框中选择“Constructor”,即可自动生成构造函数。

三、生成toString()方法

按“ALT + INSERT”键,打开Generate弹框,在Generate弹框中选择“toString()”,即可打开生成toString方法的窗口,在窗口中选择toString方法打印的属性值,点击OK即可,另外,我们再toString窗口中的Template选项出应该选择StringBuffer,这是因为如果参数过多的话,StringBuffer的效率要高于String。

四、生成hashCode和equals方法

重写hashCode和equals方法的应用场景多用于判断两个对象是否相等,例如,我们判断两个会员对象是否相等,就只需要判断会员的登录名称是否相同就行了,不用判断其他的参数是否相等,那么此时就可以重写这两个方法,参数值只需要选择会员名称即可。

 

  • 7
    点赞
  • 30
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
MyBatisCodeHelper-Pro插件免费版 Features Type safe sql support, plugin can recognize mybatis dynamic sql Code Formatter Generate mybatis crud code by Intellij database table or add a database connection Generate mybatis sql based on mybatis interface method name like spring data jpa, with this, you don't have to write most sql for non join query support generate statement with if test Database generate crud could generate multiple times when you add or delete columns, plugin will auto merge code Full mybatis sql auto complete, recognize mybatis tag in xml, like where trim set include ect,provide sql completion after those tag Jump from mybatis dao interface to mapper xml each other Refactor for mybatis interface method name,refid,resultMap ect Auto complete for mybatis param,if test,foreach,resultMap,refid in sql Generate create table sql from java class Mybatis Param refactor and inspection Ognl support, if test when test ${ bind foreach collection, refactor and inspection and auto completion Jump from refid resultMap to their definition, refactor their name as well Generate page query by mapper interface method Spring support for mybatis, inject mybatis mapper to spring bean,support SpringBoot Refid,resultMap,keyProperty,property auto complete Add @param for mapper method Resultmap column complete and inspection by parse reference select statement Auto map resultMap column and property Generate mybatis mapper testcase from mybatis interface method by database connection, make you test method quicker Full inspection for mybatis, like unused sql in xml, mapper method not have sql in xml, check if resultMap property is right ect https://github.com/gejun123456/MyBatisCodeHelper-Pro to learn more. How to use view on https://github.com/gejun123456/MyBatisCodeHelper-Pro qqGroup:914051156

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值