自定义注解
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface SystemLog {
public String description() default "";
}
用在方法上
@ResponseBody
@ValidRequestBody
@RequestMapping("/login")
@SystemLog(description="登录")
public GlobalResponse login(@RequestBody @Valid User user, BindingResult bindingResult){
......
}
获取注解的属性值
@Around("@annotation(com.xxx.xxx.xxx.SystemLog)")
public Object around(ProceedingJoinPoint joinPoint) throws Throwable{
SystemLog systemLog = ((MethodSignature)joinPoint.getSignature()).getMethod().getAnnotation(SystemLog.class);
......
}