<batch:job id="parentJob">
<batch:step id="parentJob.step1">
<batch:job ref="childJob" job-launcher="batchJobLauncher" />
</batch:step>
</batch:job>
parentJob将childJob作为一个步骤。 我将batchJobLauncher指定为childJob的启动器。
问题是弹出初始化失败并显示此错误消息。
Caused by: java.lang.IllegalArgumentException: JobRepository must be set
at org.springframework.util.Assert.notNull(Assert.java:112)
at org.springframework.batch.core.job.AbstractJob.afterPropertiesSet(AbstractJob.java:109)
at org.springframework.batch.core.configuration.xml.JobParserJobFactoryBean.getObject(JobParserJobFactoryBean.java:86)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:142)
... 136 more
作业必须有jobRepository的引用,但parentJob没有。
我很好地定义了工作存储库,另一项工作很好。
如果删除了childJob的特定启动器,则弹出初始化成功。
我调试spring代码,我发现JobParserJobFactoryBean类有null JobRepository,所以parentJob也有null。
问题是什么?
=============================================== ================================= 构造
<?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>