Reputation: 4769
I am running multiple jobs and I would like to have a separate job repository (in-memory implementation) for each job.
Please find below the bean definitions that I tried. Please note that I have tried to specify the bean with scope prototype.
I get a java.lang.IllegalArgumentException: JobExecution must already be saved
exception.
<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.SimpleJobRepository"
scope="prototype">
<constructor-arg>
<bean class="org.springframework.batch.core.repository.dao.MapJobInstanceDao"/>
</constructor-arg>
<constructor-arg>
<bean class="org.springframework.batch.core.repository.dao.MapJobExecutionDao" />
</constructor-arg>
<constructor-arg>
<bean class="org.springframework.batch.core.repository.dao.MapStepExecutionDao"/>
</constructor-arg>
<constructor-arg>
<bean class="org.springframework.batch.core.repository.dao.MapExecutionContextDao"/>
</constructor-arg>
</bean>
Upvotes: 0
Views: 7823
Reputation: 651
This one has worked for me, e.g. as a unit-test jobRepository
:
<bean id="jobRepository"
class="org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean">
</bean>
Upvotes: 1