不知道这可能是问题所在,只是在我的应用程序中添加了标准的cron作业,如果它是硬编码的,它就可以工作!
application.properties
qronicle.data-retention.retryCronSchedule = 0 * * * * *
DataRetentionDeliveryMethod
@Scheduled(cron = "\${qronicle.data-retention.retryCronSchedule}")
@Transactional
override fun run() {
LOGGER.info("Running retry job.")
val retentionRecords = retentionRepository.findAllByStateAndRetryCountLessThan()
LOGGER.info("Will attempt to reprocess ${retentionRecords.size} retention records.")
抛出以下错误
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-06-18 14:02:25.221 ERROR 20 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'retentionRetryJob$qronicle' defined in class path resource [com/netapp/qronicle/config/ApplicationConfig.class]: Initialization of bean failed; nested exception is java.lang.IllegalStateException: Encountered invalid @Scheduled method 'run': Exactly one of the 'cron', 'fixedDelay(String)', or 'fixedRate(String)' attributes is required
值得一提的是,在IntelliJ中运行应用程序似乎可以正常工作
giving the following log line...
2019-06-18 17:30:35.388 INFO 15642 --- [ main] c.n.q.p.delivery.RetentionRetryJob : Started retention retry job with schedule: 0 * * * * *.