想要在每个Job
跑之前插入一段逻辑,但如下代码经测试进不去AOP
的代码,为什么?如果实在不行,还有什么方案可以实现吗?
代码贴在下面:
@Component
public class CheckPayJob {
@Autowired
private OrderService orderService;
@Scheduled(cron="${checkPay.cron}")
public void execute() {
// some job core here
}
}
@Component
@Aspect
public class JobAspect {
@Pointcut("@annotation(org.springframework.scheduling.annotation.Scheduled)")
public void scheduledPointCut() {}
@Before("scheduledPointCut()")
public void before() throws Throwable {
String T = IdMaker.generate();
MDC.put(Constants.T, T);
}
}
直接对方法进行切入试试。。。。