当前位置: 代码迷 >> J2EE >> Spring3.1.4整合quartz2.2.1,碰到NoSuchMethodError,不会排错
  详细解决方案

Spring3.1.4整合quartz2.2.1,碰到NoSuchMethodError,不会排错

热度:50   发布时间:2016-04-17 23:27:28.0
Spring3.1.4整合quartz2.2.1,遇到NoSuchMethodError,不会排错
项目中需要用到定时器,每天凌晨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()方法,但是我检查了,方法是有的。
至于整合,我们的项目是maven管理的,我就引入了quartz的jar,然后使用的事Spring中提供的FactoryBean类,整合应该没错吧,到底是什么原因抱着个错误呢,快要疯了,求教大神!
------解决思路----------------------
提示缺失某一方法,通常是jar 版本冲突造成的...可以在ide黑头找到VisitedWebgameRepository 类,,, 找到属于的jar ,,,,在看最后的使用的jar 可能有多个版本..
------解决思路----------------------
可能是冲突了 jar重复了。
  相关解决方案