Lombok的 @Accessors(chain = true)
注解链式风格构建
Lombok的 @Builder
注解,建造者模式生成构建器
@Builder public class User { String username; String password; } // 建造者模式构建对象 User u = User.builder().username("用户名").password("密码").build();复制代码
public class User { private String username; private String password; public User(String username, String password) { this.username = username; this.password = password; } public static User.UserBuilder builder(){ return new User.UserBuilder(); } public static class UserBuilder { private String username; private String password; public User.UserBuilder username(String username){ this.username = username; return this; } public User.UserBuilder password(String password){ this.password = password; return this; } public User build(){ return new User(this.username, this.password); } } } 复制代码
使用IDEA插件Maven Helper,查看pom.xml文件,选择Dependency Analyzer,选择Conflicts即可查看冲突的依赖,直接右键选择Exclude即可排除掉冲突或重复的依赖,再点击Refresh-UI刷新检测复制代码
例如:201911200001725439这样一个Long类型数,传给前端后会变成201911200001725440
字段上使用注解:@JSONField(serializeUsing= ToStringSerializer.class)复制代码
前后分离项目的时间字段尽量不要使用时间戳存储
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date createTime;复制代码
前后端时间格式保持一致。
推荐开启 skip_name_resolve