如何在公共方法上进行注解后调用counter?

cl25kdpy  于 2021-07-13  发布在  Java
关注(0)|答案(0)|浏览(233)

这个问题在这里已经有答案了

为什么自调用对spring代理不起作用(例如使用aop)(1个答案)
spring aop不适用于另一个方法内部的方法调用(14个答案)
26天前关门了。
我有一个简单的柜台

@Aspect
@Component 
public class Countter {

  @After("@annotation(com.example.MessageAnnotation)")
  public void increment(JoinPoint point){
    //do increment
  }
}

我有消息

@Component
@AllArgsConstructor
@FieldsDefaults(level=Private, makeFinal = true)
public class Handler {

  @NotNull UserRepository repo;
  @NotNull MessageClient client;

  @MessageAnnotation // <- here annotation works, an I can pass to increment method!!!
  public void handleEvent(Event event) {
    User user = repo.fondById(event.getId);
    user.ifPresent(o - > send(o))

  }

  @MessageAnnotation // <- I need to pass to increment method from this method because the user sometimes is 
  public void send(User user) { // not present, but it doesn't work.
    //do send user
  }
}

我有什么问题?为什么我不能从另一个方法传递到增量方法?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题