因为“只有返回无效的方法可以用@Scheduled注释”,当我使用@Bean配置时如何使用SpringBatch和SpringSchedulerTask的xml配置?您可以在下面找到我的完整配置文件。当我从main()触发但只有一次时,它运行完美。我想添加@Scheduled(fixedrate=9999)以便以特定频率调用相同的作业。据我所知,为了做到这一点,我应该在step1方法周围添加@Scheduled但我不能,因为它返回的值与void不同。@Configuration@EnableBatchProcessing@EnableSchedulingpublicclassBatch
我关注了verysimpleexamples在线在Spring中设置cron作业,但我每次都在Tomcat启动日志中收到此错误:2015-05-2500:32:58DEBUGScheduledAnnotationBeanPostProcessor:191-CouldnotfinddefaultTaskSchedulerbeanorg.springframework.beans.factory.NoSuchBeanDefinitionException:Noqualifyingbeanoftype[org.springframework.scheduling.TaskScheduler]
我一直在研究如何使用Java8和spring在运行时更改作业的频率。Thisquestion非常有用,但并没有完全解决我的问题。我现在可以配置下一次执行作业的日期。但是如果将延迟设置为1年,那么我需要等待1年才能考虑到新配置。我的想法是如果配置值发生更改(因此来自另一个类),则停止计划任务。然后重新计算下一次应该执行的任务。也许有更简单的方法来做到这一点。这是我目前的代码。@Configuration@EnableSchedulingpublicclassRequestSchedulerConfigimplementsSchedulingConfigurer{@AutowiredSch
当我运行单元测试时,它会调用我的计划任务。我想防止这种行为,这是由于我的主应用配置中有@EnableScheduling造成的。如何在我的单元测试中禁用它?我遇到过这个question/answer这建议设置配置文件?不确定我会怎么做?或者如果它是一个矫枉过正?我正在考虑为我的单元测试使用单独的AppConfiguration,但是当我这样做时感觉就像我重复了两次代码?@Configuration@EnableJpaRepositories(AppConfiguration.DAO_PACKAGE)@EnableTransactionManagement@EnableSchedulin
一切的开始(@EnableScheduling)先放上示例代码@Configuration@EnableSchedulingpublicclassMainApplicationBootStrap{ @Bean publicBridebride(){ returnnewBride(); } publicstaticvoidmain(String[]args)throwsIOException{ AnnotationConfigApplicationContextannotationConfigApplicationContext=newAnnotationConfigApplication
一切的开始(@EnableScheduling)先放上示例代码@Configuration@EnableSchedulingpublicclassMainApplicationBootStrap{ @Bean publicBridebride(){ returnnewBride(); } publicstaticvoidmain(String[]args)throwsIOException{ AnnotationConfigApplicationContextannotationConfigApplicationContext=newAnnotationConfigApplication