使用spring注解来调度定时任务时报错:Unexpected error occurred in scheduled task.

在用spring注解来调度定时任务时,报了个这样的错:
2018-04-26 19:08:40 [ERROR] [org.springframework.scheduling.support.TaskUtils$LoggingErrorHandler.handleError:95] - Unexpected error occurred in scheduled task.
 java.lang.IllegalArgumentException: object is not an instance of declaring class
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:64)
	at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:53)
	at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)

网上找了半天也没找到解决办法,后来发现是因为我这个类是个实现类,把implements给去掉就好了。

public class UpdateAttendanceTypeQuartzManagerImpl implements UpdateAttendanceTypeQuartzManager

在这里也转载下spring使用注解来调度定时任务的方法:

https://blog.csdn.net/qq_33556185/article/details/51852537


你可能感兴趣的:(使用spring注解来调度定时任务时报错:Unexpected error occurred in scheduled task.)