Spring Batch: Job Properties -
how can add property:
<property name="myproperty" value="value"/>
to batch job definition:
<batch:job id="myjob"> <batch:description>description</batch:description> <batch:step id="step0"> <batch:tasklet ref="myjobcls"/> <batch:listeners> <batch:listener ref="myjobklistener"/> </batch:listeners> </batch:step> </batch:job>
then can use property in run time.
you can have properties in external file or inject in propertyplaceholderconfigurer xml:
<bean id="propertyconfigurer" class="org.springframework.beans.factory.config.propertyplaceholderconfigurer"> <property name="location"><value>my_config.properties</value></property> <property name="properties"> <props> <prop key="myproperty">value</prop> </props> </property> </bean>
more details here: using properties in spring config
also if run process using commandlinejobrunner can set command line using -d (how read jvm arguments in spring applicationcontext.xml) a-dmyproperty=value
for myproperty value in myjobcls/myjobklistener have @ leas options:
annotations how can inject property value spring bean configured using annotations?
or inject xml config: http://www.mkyong.com/spring/spring-propertyplaceholderconfigurer-example/