1
我在Grails 3.1.9中使用@Scheduled
注解,从3.1.0.RC2升级到3.1.9后,注释的服务方法根本没有执行。降级回到3.1.0.RC2会导致它再次工作。升级到Grails后,@ Scheduled Annotation失败3.1.9
这里是我的服务...
package com.mycompany.app
import grails.transaction.Transactional
import org.springframework.scheduling.annotation.Scheduled
@Transactional
class InstanceSnapshotService {
@Scheduled(fixedDelay = 30000L, initialDelay = 30000L)
void updateSnapshots() {
Date start = new Date()
log.info("Started Updating Snapshots at $start")
... do stuff ...
log.info("Finished Updating Snapshots after ${new Date().time - start.time}ms")
}
}
这里是我的Application.groovy ...
package com.datapriviasoftware.completesso
...
import org.springframework.scheduling.annotation.EnableScheduling
@EnableScheduling
class Application extends GrailsAutoConfiguration implements EnvironmentAware {
static void main(String[] args) {
GrailsApp.run(Application)
}
@Override
void setEnvironment(Environment environment) {
...
}
}
就像我说的,我之前我们有这个运行了几个星期前从Grails 3.1.0-RC2升级到Grails 3.1.9。我不确定这可能与它有什么关系。
非常感谢您提供任何帮助。
你在某处注册'InstanceSnapshotService'吗?您可能缺少'@ Service'插入。 – Loucher
Grails根据约定注册服务而不使用@ @ Service注解,但我尝试添加注解以防万一,但无济于事。 (还是)感谢你的建议。 :-) – 10GritSandpaper
只是恢复到3.1.0.RC2工作正常。所以在3.1.0.RC2和3.1.9之间'@ Scheduled'看起来有些变化。现在调查以确定在哪里。 –