[英]Spring injecting implementation bean
我有一个来自conf spring文件的以下代码片段:
<bean id="taskletStep" abstract="true" class="org.springframework.batch.core.step.tasklet.TaskletStep">
<property name="jobRepository" ref="jobRepository"/>
<property name="transactionManager" ref="transactionManager"/>
</bean>
<bean id="hello" class="com.techavalanche.batch.PrintTasklet">
<property name="message" value="Hello"/>
</bean>
<bean id="world" class="com.techavalanche.batch.PrintTasklet">
<property name="message" value=" World!"/>
</bean>
<bean id="mySimpleJob" class="org.springframework.batch.core.job.SimpleJob">
<property name="name" value="mySimpleJob" />
<property name="steps">
<list>
<bean parent="taskletStep">
<property name="tasklet" ref="hello"/>
</bean>
<bean parent="taskletStep">
<property name="tasklet" ref="world"/>
</bean>
</list>
</property>
对我来说,以下内容不是很清楚:
<bean parent="taskletStep">
<property name="tasklet" ref="hello"/>
</bean>
taskletStep它是一个接口,没有任何属性。 但是代码运行正常,似乎注入了ID为“ hello”的bean。 因此,我想问一下,这是从配置文件向接口Bean(id: taskletStep )注入bean实现(id: hello )的标准方法吗?
这是Spring Batch Job中的Tasklet步骤。 您在做什么很好。 另外,您也可以执行以下操作:
<job id="mySimpleJob">
<step id="step1">
<tasklet ref="hello"/>
</step>
<step id="step2">
<tasklet ref="world"/>
</step>
</job>
这里是完整的参考: http : //docs.spring.io/spring-batch/reference/htmlsingle/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.