Spring相关注解大全

1.数据相关

1.1 Lombok

注解注释
@Dataset and get,equals,hashcode()
@Accessors(chain = true)生成链式赋值的set方法
@AllArgsConstructor自动生成包含全部参数的构造方法
@NoArgsConstructor自动生成无参构造方法


1.2 SpringData

注解注释
@Document注解标记当前类和ES关联
indexName指定索引名称,我们这里叫items,当操作这个索引时,如果索引不存在,会自动创建
@IdSpingData标记这个字段为当前类主键
@FieldSpringData使用@Field标记文档中属性的类型和各种特征
type = FieldType.Text, analyzer = “ik_max_word”, searchAnalyzer = “ik_max_word”
type = FieldType.Keyword /Double , index = false


1.3 Spring Security

注解注释
@PreAuthorizeController层用户登录权限验证注解
@PreAuthorize(“hasRole(‘ROLE_user’)”)- hasRole判断是专用于判断当前用户角色的指令
@PreAuthorize(“hasRole(‘user’)”)- hasRole会自动在我们判断的内容前添加ROLE_
@PreAuthorize(“hasAuthority(‘/pms/product/read’)”)通用指令
@PreAuthorize(“hasAuthority(‘ROLE_user’)”)通用指令

1.4 Knife4j

注解注释
@Api作用于类
@ApiOperation作用于方法
@ApiImplicitParam()作用于单个参数
@ApiImplicitParams({@ApiImplicitParam()})作用于多个参数

1.5 Sentinel限流

注解注释
@SentinelResource(value = “商品购买”,blockHandler = “blockError”,fallback = “fallBack”)限流,降级

1.6 Spring Aop

注解注释
@Aspect表示当前类不是普通类,是做切面功能的实现
@Pointcut指定切面方法的注解
@Before切面–>前置通知
@After切面–>后置通知
@AfterThrowing类似于spring的异常处理类,捕获


2.0 其他默认值参数注解

注解注释
@RequestParam参数注解, 提供默认参数
@Deprecated弃用当前类
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

pigerr杨

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值