一、spring boot 启动类
@SpringBootApplication spring boot 启动注解
@EnableScheduling 项目启用延时方法的注解 与@Scheduled 一起使用
二、spring boot 实体类
1.lombok(插件相关)
@NonNull : 注解在参数上, 如果该类参数为 null , 就会报出异常, throw new NullPointException(参数名)
@Cleanup : 注释在引用变量前, 自动回收资源 默认调用 close() 方法
@Getter/@Setter : 注解在类上, 为类提供读写属性
@Getter(lazy=true) :
@ToString : 注解在类上, 为类提供 toString() 方法
@EqualsAndHashCode : 注解在类上, 为类提供 equals() 和 hashCode() 方法
@NoArgsConstructor, @RequiredArgsConstructor, @AllArgsConstructor : 注解在类上, 为类提供无参,有指定必须参数, 全参构造函数
@Data : 注解在类上, 为类提供读写属性, 此外还提供了 equals()、hashCode()、toString() 方法
@Builder : 注解在类上, 为类提供一个内部的 Builder
@Synchronized : 注解在方法上, 为方法提供同步锁
@Log4j : 注解在类上, 为类提供一个属性名为 log 的 log4j 的日志对象
@Slf4j : 注解在类上, 为类提供一个属性名为 log 的 log4j 的日志对象
@Entity 说明这个class是实体类,并且使用默认的orm规则,即class名即数据库表中表名,class字段名即表中的字段名 @Table(name = "user") 如果想改变这种默认的orm规则,就要使用@Table来改变class名与数据库中表名的映射规则, @Column来改变class中字段名与db中表的字段名的映射规则
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm") 时间格式化
@JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") 时间格式化
三、spring boot 接口类
@Repository @Repository跟@Service,@Compent,@Controller这4种注解是没什么本质区别,都是声明作用,取不同的名字只是为了更好区分各自的功能。
//spring boot 方法类
@Scheduled 延时方法上使用的注解
//spring boot 控制类