@DisallowConcurrentExecution
@Component
public class QuartzJobFactoryImpl implements Job {
// 消费
@Lazy
@Autowired
@Resource(name="channelDaiHuanPayService")
private ChannelDaiHuanPayService channelDaiHuanPayService;
// 代还
@Lazy
@Autowired
@Resource(name="channelDaiHuanDrawService")
private ChannelDaiHuanDrawService channelDaiHuanDrawService;
public void execute(JobExecutionContext context) throws JobExecutionException {
SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
System.out.println("========任务成功运行========");
// 生成任务参数对象
ScheduleJob scheduleJob = (ScheduleJob)context.getMergedJobDataMap().get("scheduleJob");
System.out.println("任务名称 = [" + scheduleJob.getJobName() + "]");
// 区分还款和消费
if ("billConsumption".equals(scheduleJob.getJobType())) {
// 消费
channelDaiHuanPayService.pay(scheduleJob);
return ;
}
// 代还
channelDaiHuanDrawService.draw(scheduleJob);
}
}
解决办法:
1.@Resource(name="channelDaiHuanPayService")
2.SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);