我正在使用Spring 3.2.11.RELEASE和Quartz 1.8.5。我正在尝试设置一个Quartz作业来对标记为@Transactional的类执行方法。以下是界面......
public interface MyDataService
{
…
void downloadAndProcessMyDataMatchedFiles();
这是实施类......
@Service("MyDataService")
@Transactional
public class MyDataServiceImpl extends AbstractCleverUserService implements MyDataService
{
…
@Override
public void downloadAndProcessMyDataMatchedFiles()
{
…
我在我的dispatcher-servlet.xml文件中设置了这个...
<bean id="processMatchedDatasFileJob"
class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="MyDataService" />
<property name="targetMethod" value="downloadAndProcessMyDataMatchedFile" />
<property name="concurrent" value="false" />
</bean>
<bean id="processMatchedDatasCronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail" ref="processMatchedDatasFileJob" />
<property name="cronExpression" value="${process.matched.students.schedule}" />
</bean>
但是,我收到了这个错误......
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'processMatchedDatasFileJob' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodException: com.sun.proxy.$Proxy530.downloadAndProcessMyDataMatchedFile()
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1514)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:191)
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:618)
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:934)
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:651)
org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:602)
org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:665)
org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:521)
org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:462)
org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
javax.servlet.GenericServlet.init(GenericServlet.java:242)
org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:165)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:372)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:679)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:931)
java.lang.Thread.run(Thread.java:745)
如何让我的Quartz作业尽可能少地工作?
答案 0 :(得分:0)
方法名称拼写不正确,请更改
<property name="targetMethod" value="downloadAndProcessMyDataMatchedFile"/>
进入
<property name="targetMethod" value="downloadAndProcessMyDataMatchedFiles"/>