引入lombok:
<!--lombok-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
实体创建:
@Data
@Builder(toBuilder=true)
@AllArgsConstructor
@NoArgsConstructor
public class UserInfoBO implements BaseReq, BaseRsp {
private String id;
private String userNm;
private String password;
}
属性初始化
UserInfoBO jerry = UserInfoBO.builder().id("123").userNm("jerry").password("666").build();
属性修改
UserInfoBO tom = jerry.toBuilder().userNm("tom").password("888").build();