我有 Spring boot 应用程序AspectJ配置为在一项服务返回数据后异步工作,但这有时无法触发,只有没有错误日志没有警告,这可以随时发生,如果我错过了任何 conf,请告诉我?
应用代码
@SpringBootApplication
@EnableAspectJAutoProxy
@EnableAsync
public class TitlesCompareUtilityApplication {
public static void main(String[] args) {
SpringApplication.run(TitlesCompareUtilityApplication.class, args);
}
}
方面代码
@Aspect
@Component
public class DistributedLoggingAspect {
private static Logger log = LoggerFactory.getLogger(DistributedLoggingAspect.class);
@Async
@AfterReturning("execution(* com.mycomp.repo.TyRepository.findById(..))")
public void logAfterReturn(JoinPoint joinPoint) {
int id = (int) joinPoint.getArgs()[0];
log.info("logAfterReturn() is running! id:{}", id);
}
}