Spring批处理中的内存中Job-Explorer定义

时间:2013-10-14 16:45:11

标签: spring-batch

我试图将我的内存中的jobRepository共享给jobExplorer。但它会引发错误,

嵌套异常是

org.springframework.beans.ConversionNotSupportedException:
Failed to convert property value of type '$Proxy1 implementing
org.springframework.batch.core.repository.JobRepository,org.
springframework.aop.SpringProxy,org.springframework.aop.framework.Advised'
to required type

即使我尝试过'&'在传递给jobExplorer进行共享时,在jobRepository之前签名。但是尝试结束是徒劳的。

我正在使用Spring Batch 2.2.1

jobExplorer的依赖项是否只是数据库不在内存中?

定义是,

<bean id="jobRepository"
        class="com.test.repository.BatchRepositoryFactoryBean">
        <property name="cache" ref="cache" />
        <property name="transactionManager" ref="transactionManager" />
</bean>

<bean id="jobOperator" class="test.batch.LauncherTest.TestBatchOperator">
        <property name="jobExplorer" ref="jobExplorer" />
        <property name="jobRepository" ref="jobRepository" />
        <property name="jobRegistry" ref="jobRegistry" />
        <property name="jobLauncher" ref="jobLauncher" />
</bean>

<bean id="jobExplorer" class="test.batch.LauncherTest.TestBatchExplorerFactoryBean">
        <property name="repositoryFactory" ref="&jobRepository" />
</bean>  


    <bean id="transactionManager"
        class="org.springframework.batch.support.transaction.ResourcelessTransactionManager" />

    <bean id="jobLauncher" class="com.scb.smartbatch.core.BatchLauncher">
        <property name="jobRepository" ref="jobRepository" />
    </bean>

    <!-- To store Batch details -->
    <bean id="jobRegistry" class="com.scb.smartbatch.repository.SmartBatchRegistry" />

    <bean id="jobRegistryBeanPostProcessor"
        class="org.springframework.batch.core.configuration.support.JobRegistryBeanPostProcessor">
        <property name="jobRegistry" ref="jobRegistry" />
    </bean>

    <!--Runtime cache of batch executions -->
    <bean id="cache" class="com.scb.cache.TCRuntimeCache" />

2 个答案:

答案 0 :(得分:0)

通常你必须连接接口而不是实现 否则,您可能需要添加<aop:config proxy-target-class="true">来创建基于CGLIB的代理而不是标准的基于Java的代理。
阅读Spring official documentation关于

的内容

答案 1 :(得分:0)

感谢您的宝贵意见。

但是我在作业存储库引用之前使用了'&amp;',这允许我将它用作我的作业资源管理器作为共享资源。

问题解决了。

荣誉。