在切面的注解中使用@Within代替@Annotation。例如:

    @Before("@annotation(DataSource)")          其中DataSource为自定义注解

改为  @Before("@within(DataSource)")

 

ps:

@within:用于匹配所有持有指定注解类型内的方法;

@target:用于匹配当前目标对象类型的执行方法,其中目标对象持有指定的注解;

@args:用于匹配当前执行的方法传入的参数持有指定注解的执行;

@annotation:用于匹配当前执行方法持有指定注解的方法。