Mybatis知识小汇(8)——使用Lombok
作者:互联网
Lombok
-
安装Lombok插件
-
导入lombok的jar包
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.12</version>
</dependency>
Features:
@Getter and @Setter
@FieldNameConstants
@ToString
@EqualsAndHashCode
@AllArgsConstructor, @RequiredArgsConstructor and @NoArgsConstructor
@Log, @Log4j, @Log4j2, @Slf4j, @XSlf4j, @CommonsLog, @JBossLog, @Flogger, @CustomLog
@Data
@Builder
@SuperBuilder
@Singular
@Delegate
@Value
@Accessors
@Wither
@With
@SneakyThrows
@val
@var
experimental @var
@UtilityClass
@ExtensionMethod (Experimental, activate manually in plugin settings)
Lombok config system
Code inspections
Refactoring actions (lombok and delombok)
@Data:无参构造、get()、set()、toString()、equals()、hashCode()
@AllArgsConstructor:有参构造
@NoArgsConstructor:无参构造
@Data
@AllArgsConstructor
@NoArgsConstructor
//可以自动生成我们常用的方法
public class User {
private int id;
private String name;
private String pwd;
}
上一节—>使用注解开发
如有不对的地方欢迎指出,共同进步!
标签:NoArgsConstructor,小汇,private,AllArgsConstructor,Mybatis,Lombok,Data,lombok 来源: https://blog.csdn.net/weixin_45734378/article/details/113781046