Closed Alice52 closed 2 years ago
@Mobile
@Constraint(validatedBy = MobileDescriptor.class)
[@Email]
ConstraintValidator
@Transactional
@Around
@RocketMQBasedDelay
@LocalIdempotentRequest
@LocalLimitRequest
@DeSensitive
@DateTimeFormat
spring annotation
注解 + 切面
ListableBeanFactory.findAnnotationOnBean(String beanName, Class<A> annotationType)
AnnotationUtils.findAnnotation(Class<?> clazz, Class<A> annotationType)
使用DLBF获取被指定注解修饰的类: AnnotationUtils.getAnnotation(Method method, Class<A> annotationType)
AnnotationUtils.getAnnotation(Method method, Class<A> annotationType)
public static <A extends Annotation> A findAnnotationOnBean( String beanName, Class<A> annotationType) { AbstractApplicationContext context = (AbstractApplicationContext) ApplicationContextHolder.getInstance(); ConfigurableListableBeanFactory beanFactory = context.getBeanFactory(); return Optional.of(beanFactory) .map(each -> (RootBeanDefinition) beanFactory.getMergedBeanDefinition(beanName)) .map(RootBeanDefinition::getResolvedFactoryMethod) .map(factoryMethod -> AnnotationUtils.getAnnotation(factoryMethod, annotationType)) .orElse(null); }
how to define?
@ParamsValidate(value = {@ParamValidate(name = "name", notNull = true, message = "不能为空", maxLen = 200)})
type
@Mobile
]:@Constraint(validatedBy = MobileDescriptor.class)
[@Email]
: EmailValidator: 创建 validator是会内置ConstraintValidator
@Transactional
]: aop 上做拦截: 可以使用@Around
注解做拦截 || MethodInterceptor + DefaultPointcutAdvisor + AnnotationMatchingPointcut@RocketMQBasedDelay
@LocalIdempotentRequest
@LocalLimitRequest
@DeSensitive
]: 数据脱敏, 序列化相关@DateTimeFormat
]: 屏蔽底层细节-运行时参数类型获取对应的 Parser/Printer 进行工作spring annotation
注解 + 切面
ListableBeanFactory.findAnnotationOnBean(String beanName, Class<A> annotationType)
AnnotationUtils.findAnnotation(Class<?> clazz, Class<A> annotationType)
使用DLBF获取被指定注解修饰的类:
AnnotationUtils.getAnnotation(Method method, Class<A> annotationType)
issue list
how to define?
reference