サービスレイヤークラスに@Scheduledアノテーションを使用しようとしています。このクラスは、AOPを介したロギングサービスによっても監視されます。
サービスクラスにインターフェイスを実装させると、Springはエラーをスローします
Error creating bean with name 'dummyService' defined in file
......
......
Caused by: java.lang.IllegalStateException: failed to prepare task
at org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor$1.doWith(ScheduledAnnotationBeanPostProcessor.java:114)
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:452)
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:430)
at org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor.postProcessAfterInitialization(ScheduledAnnotationBeanPostProcessor.java:98)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:407)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1426)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
... 11 more
Caused by: java.lang.NoSuchMethodException: $Proxy23.run()
at java.lang.Class.getMethod(Class.java:1605)
at org.springframework.util.MethodInvoker.prepare(MethodInvoker.java:178)
at org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor$1.doWith(ScheduledAnnotationBeanPostProcessor.java:111)
... 17 more
これはサービスレイヤークラスです。
package com.mydomain.web.myapp.service;
@Service
public class DummyService implements DummyI{
@Scheduled(cron = "${some.cron.time}")
public void run() {
}
}
継承を削除すると、問題なく動作します。何故ですか?
これは私がロギングサービスのために持っているものです:
@Component
@Aspect
public class LoggingServiceImpl implements LoggingService {
private final Logger log = LoggerFactory.getLogger(this.getClass());
@Around("execution(* com.mydomain.web.myapp..*.*(..))")
public Object log(ProceedingJoinPoint joinPoint) throws Throwable {
.....