当我将Spring Batch作业定义如下:
<batch:job id="FailTask">
<batch:description>My Job Description</batch:description>
<batch:step id="FailTask-step0">
<batch:tasklet ref="sampleFailTask" />
<batch:listeners>
<batch:listener ref="sampleFailStepListener" />
</batch:listeners>
</batch:step>
</batch:job>
我如何在我的java代码中获得职位描述?
答案 0 :(得分:1)
好的,我找到了它:
AutowireCapableBeanFactory beanFactory = applicationContext.getAutowireCapableBeanFactory()
BeanDefinition beanDefinition = ((BeanDefinitionRegistry) beanFactory).getBeanDefinition(taskName);
String taskDescription = beanDefinition.getDescription();
现在的问题是如何获得除描述之外的其他属性?
答案 1 :(得分:0)
在JobParser中有行:
Element description = DomUtils.getChildElementByTagName(element, "description");
if (description != null) {
builder.getBeanDefinition().setDescription(description.getTextContent());
}
因此,描述设置为bean defenition。你可以从BeanDefinitionRegistry获得它。