我正在尝试从后台向导处理程序执行cronjob。
myHandler从其perform()调用executeJob():
private void executeJob() {
String springId = "myJobPerformable";
String id = springId;
JobModel myJob = getJob(springId).orElseGet(createJob(id, springId));
id = String.valueOf(this.keyGenerator.generate());
CronJobModel myCronJob = createCronJob(id, myJob);
this.cronJobService.performCronJob(myCronJob);
}
private Optional<JobModel> getJob(String springId) {
ServicelayerJobModel myJob = new ServicelayerJobModel();
myJob.setSpringId(springId);
try {
return Optional.ofNullable(flexibleSearchService.getModelByExample(myJob));
} catch (ModelNotFoundException e) {
return Optional.empty();
}
}
private Supplier<JobModel> createJob(String id, String springId) {
return () -> {
ServicelayerJobModel myJob = modelService.create(ServicelayerJobModel.class);
myJob.setCode(id);
myJob.setSpringId(springId);
modelService.save(myJob);
return myJob;
};
}
private MyCronJobModel createCronJob(String id, JobModel myJob) {
MyCronJobModel myCronJob = this.modelService.create(MyCronJobModel.class);
myCronJob.setCode(id);
myCronJob.setActive(Boolean.TRUE);
myCronJob.setJob(myJob);
myCronJob.setSessionUser(this.userService.getCurrentUser());
myCronJob.setSessionLanguage(this.commonI18NService.getCurrentLanguage());
myCronJob.setSessionCurrency(this.commonI18NService.getCurrentCurrency());
this.modelService.save(myCronJob);
return myCronJob;
}
此代码运行时发生问题,它引发没有名为'myJobPerformable'的bean。
但是,该bean已经在mybackoffice-backoffice-spring.xml中注册了
答案 0 :(得分:3)
好像您将bean定义从mybackoffice-backoffice-spring.xml
移到mybackoffice-spring.xml
一样,应该对其进行修复,因为您的bean随后将被注册到应用程序上下文中并且可用于服务层。
希望有帮助!