Spring批处理作业jobrepository为空
我做过一份这样的工作Spring批处理作业jobrepository为空,spring,spring-batch,Spring,Spring Batch,我做过一份这样的工作 <batch:job id="parentJob"> <batch:step id="parentJob.step1"> <batch:job ref="childJob" job-launcher="batchJobLauncher" /> </batch:step> </batch:job> 作业必须具有jobRepository的引用,但parentJob没有 我很好地定义了
<batch:job id="parentJob">
<batch:step id="parentJob.step1">
<batch:job ref="childJob" job-launcher="batchJobLauncher" />
</batch:step>
</batch:job>
作业必须具有jobRepository的引用,但parentJob没有
我很好地定义了作业存储库,其他作业也可以使用它
如果删除childJob的特定启动器,则spring初始化成功
我调试spring代码,发现JobParserJobFactoryBean类的JobRepository为null,因此parentJob也为null
- 版本信息
- 弹簧3.2.0.1释放
- 弹簧批次2.1.8.1发布
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:hdp="http://www.springframework.org/schema/hadoop"
xmlns:batch="http://www.springframework.org/schema/batch"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/hadoop http://www.springframework.org/schema/hadoop/spring-hadoop.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch.xsd">
<!-- required since Job is a class not an interface -->
<bean class="org.springframework.batch.core.scope.StepScope" p:proxyTargetClass="true" />
<bean id="jobLauncher" class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
<property name="jobRepository" ref="jobRepository" />
</bean>
<bean id="jobRepository" class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean">
<property name="databaseType" value="oracle" />
<property name="dataSource" ref="commonDataSource" />
<property name="transactionManager" ref="transactionManager" />
<property name="isolationLevelForCreate" value="ISOLATION_DEFAULT" />
<property name="lobHandler" ref="oracleLobHandler" />
</bean>
<bean id="nativeJdbcExtractor" class="org.springframework.jdbc.support.nativejdbc.OracleJdbc4NativeJdbcExtractor">
<property name="connectionType" value="oracle.jdbc.OracleConnection" />
</bean>
<bean id="oracleLobHandler" class="org.springframework.jdbc.support.lob.OracleLobHandler">
<property name="nativeJdbcExtractor" ref="nativeJdbcExtractor" />
</bean>
</beans>
有几件事:1。最好同时升级Spring和Spring Batch的两个版本。2.你能发布你的完整配置吗?您上面的配置没有您的JobRepository
定义。我将发布我的配置。这两个配置如何关联?很抱歉,迟到了。applicationContext.xml(has jobRepository conf)import batch context.xml(has spring batch job conf)您确定两者都找到了吗?
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:hdp="http://www.springframework.org/schema/hadoop"
xmlns:batch="http://www.springframework.org/schema/batch"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/hadoop http://www.springframework.org/schema/hadoop/spring-hadoop.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch.xsd">
<!-- required since Job is a class not an interface -->
<bean class="org.springframework.batch.core.scope.StepScope" p:proxyTargetClass="true" />
<bean id="jobLauncher" class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
<property name="jobRepository" ref="jobRepository" />
</bean>
<bean id="jobRepository" class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean">
<property name="databaseType" value="oracle" />
<property name="dataSource" ref="commonDataSource" />
<property name="transactionManager" ref="transactionManager" />
<property name="isolationLevelForCreate" value="ISOLATION_DEFAULT" />
<property name="lobHandler" ref="oracleLobHandler" />
</bean>
<bean id="nativeJdbcExtractor" class="org.springframework.jdbc.support.nativejdbc.OracleJdbc4NativeJdbcExtractor">
<property name="connectionType" value="oracle.jdbc.OracleConnection" />
</bean>
<bean id="oracleLobHandler" class="org.springframework.jdbc.support.lob.OracleLobHandler">
<property name="nativeJdbcExtractor" ref="nativeJdbcExtractor" />
</bean>
</beans>