| @Data |
| @EqualsAndHashCode(of = {"id"}) |
| public class UserInfoData { |
| private Long id; |
| private String name; |
| private String phone; |
| private Date birthDay; |
| private String address; |
| } |
| @Accessors( |
| |
| fluent = true |
| ) |
| public class UserInfoAccessors { |
| private Long id; |
| private String name; |
| private String phone; |
| private Date birthDay; |
| private String address; |
| } |
-
测试

-
Builder
| @Builder |
| public class User { |
| private Long id; |
| private String name; |
| private String phone; |
| private Date birthDay; |
| private String address; |
| } |
| public class User { |
| private Long id; |
| private String name; |
| private String phone; |
| private Date birthDay; |
| private String address; |
| |
| User(Long id, String name, String phone, Date birthDay, String address) { |
| this.id = id; |
| this.name = name; |
| this.phone = phone; |
| this.birthDay = birthDay; |
| this.address = address; |
| } |
| |
| public static User.UserBuilder builder() { |
| return new User.UserBuilder(); |
| } |
| |
| public static class UserBuilder { |
| private Long id; |
| private String name; |
| private String phone; |
| private Date birthDay; |
| private String address; |
| |
| UserBuilder() { |
| } |
| |
| public User.UserBuilder id(Long id) { |
| this.id = id; |
| return this; |
| } |
| |
| public User.UserBuilder name(String name) { |
| this.name = name; |
| return this; |
| } |
| |
| public User.UserBuilder phone(String phone) { |
| this.phone = phone; |
| return this; |
| } |
| |
| public User.UserBuilder birthDay(Date birthDay) { |
| this.birthDay = birthDay; |
| return this; |
| } |
| |
| public User.UserBuilder address(String address) { |
| this.address = address; |
| return this; |
| } |
| |
| public User build() { |
| return new User(this.id, this.name, this.phone, this.birthDay, this.address); |
| } |
| |
| public String toString() { |
| return "User.UserBuilder(id=" + this.id + ", name=" + this.name + ", phone=" + this.phone + ", birthDay=" + this.birthDay + ", address=" + this.address + ")"; |
| } |
| } |
| } |
| public class Test { |
| public static void main(String[] args) { |
| User.UserBuilder builder = User.builder(); |
| User user = builder.id(1L).build(); |
| System.out.print(user); |
| } |
| } |
| # 导入依赖 |
| <dependency> |
| <groupId>ch.qos.logback</groupId> |
| <artifactId>logback-classic</artifactId> |
| <version>1.2.3</version> |
| </dependency> |
| |
| # 写法1 |
| public class UserInfoService { |
| private static final Logger LOGGER = LoggerFactory.getLogger(UserInfoService.class); |
| public List<UserInfo> getAll() { |
| LOGGER.info("进入getAll方法"); |
| return new ArrayList<>(); |
| } |
| } |
| |
| # 写法2 |
| @Slf4j |
| public class UserInfoService { |
| public List<UserInfo> getAll() { |
| log.info("进入getAll方法"); |
| return new ArrayList<>(); |
| } |
| } |
jsr |
描述 |
相关实现 |
jsr107 |
缓存规范 |
spring基于此实现的缓存体系 |
jsr250 |
java平台Common Annotations 如@PostConstruct |
spring |
jsr269 |
Pluggable Annotation Processing API |
lombok,mapstruct |
jsr303,jsr349,jsr380 |
bean validation |
hibernate-validitor |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 一文读懂知识蒸馏
· 终于写完轮子一部分:tcp代理 了,记录一下