如何在标记为@Transactional 的方法上设置 Spring Quartz 作业?

How do I set up a Spring Quartz job on a method marked as @Transactional?

我正在使用 Spring 3.2.11.RELEASE 和 Quartz 1.8.5。我正在尝试设置一个 Quartz 作业以在标记为 @Transactional 的 class 上执行一个方法。下面是界面…

public interface MyDataService
{
    …
    void downloadAndProcessMyDataMatchedFiles();

这是实施 class …

@Service("MyDataService")
@Transactional
public class MyDataServiceImpl extends AbstractCleverUserService implements MyDataService
{
    …
    @Override
    public void downloadAndProcessMyDataMatchedFiles()
    {
    …

我在我的调度程序中设置了这个-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.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 工作尽可能少地工作吗?

方法名拼写错误,请修改

<property name="targetMethod" value="downloadAndProcessMyDataMatchedFile"/>

进入

<property name="targetMethod" value="downloadAndProcessMyDataMatchedFiles"/>