Spring注解转换

6月 29, 2023 |
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Inherited
@Documented
@SentinelResource
public @interface MySentinelResource {
    @AliasFor(annotation = SentinelResource.class)
    String value() default "";
}

// 将MySentinelResource实例转换成SentinelResource实例
SentinelResource annotation = MergedAnnotations
	.from(originMethod, MergedAnnotations.SearchStrategy.TYPE_HIERARCHY)
	.get(SentinelResource.class).synthesize();

Posted in: WEB开发

Comments are closed.