项目中需要用到定时器,每天凌晨1点读取数据库表中tb_visited_webgame中的数据,然后加工一下,将数据插入tb_site_activation表中。 <bean id="siteActivationJob" class="com.mxth.matrix2.admin.web.quartz.SiteActivationJob"/> <bean id="activationJobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> <property name="concurrent" value="false"/> <property name="targetObject"> <ref bean="siteActivationJob"/> </property> <property name="targetMethod" value="execute"/> </bean> <bean id="myTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean"> <property name="jobDetail"> <ref bean="activationJobDetail"/> </property> <property name="cronExpression"> <value>0 56 14 * * ?</value> </property> </bean> <bean id="scheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> <property name="triggers"> <list> <ref bean="myTrigger"></ref> </list> </property> </bean> Job类: public class SiteActivationJob { @Autowired private SiteActivationProcessService siteActivationProcessService; @Autowired private SiteActivationStatisticsService siteActivationStatisticsService; @Autowired private VisitedWebgameService visitedWebgameService; public SiteActivationJob(VisitedWebgameService visitedWebgameService){ this.visitedWebgameService = visitedWebgameService; } public SiteActivationJob(){} public void execute(){ List<VisitedWebgame> visitedWebgameList = visitedWebgameService.readPreDayData(); Map<Integer,SiteActivation> map = siteActivationProcessService.processData(visitedWebgameList); for(Integer websiteId:map.keySet()){ SiteActivation siteActivation = map.get(websiteId); siteActivationStatisticsService.insert(websiteId, siteActivation.getActivationDate(), siteActivation.getActivation(), siteActivation.getGmtCreate(), siteActivation.getGmtModified()); } } } 错误堆栈: Job DEFAULT.activationJobDetail threw an unhandled Exception: [scheduler_Worker-1] org.springframework.scheduling.quartz.JobMethodInvocationFailedException: Invocation of method ""execute"" on target class [class com.mxth.matrix2.admin.web.quartz.SiteActivationJob] failed; nested exception is java.lang.NoSuchMethodError: com.mxth.matrix2.share.dal.VisitedWebgameRepository.readPreDayData()Ljava/util/List; at org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean$MethodInvokingJob.executeInternal(MethodInvokingJobDetailFactoryBean.java:320) ~[spring-context-support-3.1.4.RELEASE.jar:3.1.4.RELEASE] at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:113) ~[spring-context-support-3.1.4.RELEASE.jar:3.1.4.RELEASE] 提示VisitedWebgameRepository中没有readPreDayData()方法,但是我检查了,方法是有的。 |
|
把项目和tomcat都clean一下,然后重启tomcat试试
|
|
35分 |
提示缺失某一方法,通常是jar 版本冲突造成的…可以在ide黑头找到VisitedWebgameRepository 类,,, 找到属于的jar ,,,,在看最后的使用的jar 可能有多个版本..
|
5分 |
可能是冲突了 jar重复了。
|