当我使用ref属性定义一个tasklet时,一切都很好:
<step id="unzipFiles_010_014" next="verifyXmlSignatures_010_014">
<tasklet ref="unzipTasklet_010_014" />
</step>但是,对于某些情况,我希望将bean直接定义为嵌套bean,例如:
<step id="unzipFiles_010_014" next="verifyXmlSignatures_010_014">
<tasklet>
<bean scope="step" class="some.package.UnZipTasklet">
<property name="file" ref="any.file" />
</bean>
</tasklet>
</step>现在我遇到了一个奇怪的错误:
cvc-complex-type.2.4.a: Invalid content was found starting with
element 'bean'. One of '{"http://
www.springframework.org/schema/batch":chunk,
"http://www.springframework.org/schema/
batch":transaction-attributes,
"http://www.springframework.org/schema/batch":no-rollback-exception-classes,
"http://www.springframework.org/schema/batch":listeners,
"http://www.springframework.org/schema/ beans":bean,
"http://www.springframework.org/schema/beans":ref}' is expected.这是豆子,不是吗?
在定义验证器(DefaultJobParametersValidator)时,我也遇到了同样的奇怪行为。
发布于 2012-09-28 09:39:48
可能会使用批处理:命名空间。
例如:
<batch:step id="copyToWorkdir" next="concatStrings">
<batch:tasklet>
<bean class="your.tasklet.Class" scope="step">
<property name="inFile" value="xxx" />
<property name="outFile" value="xxx" />
</bean>
</batch:tasklet>
</batch:step>发布于 2014-06-12 07:03:06
你也可以这样做:
<step id="unzipFiles_010_014" next="verifyXmlSignatures_010_014">
<tasklet ref="unZipTasklet" scope="step">
</tasklet>
</step>和以前一样:
<bean id="unZipTasklet" class="some.package.UnZipTasklet">
<property name="file" ref="any.file" />
</bean>但就像maxhax说的,这只是一个命名空间问题.尝试maxhas的示例和这个命名空间配置:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:batch="http://www.springframework.org/schema/batch"
xsi:schemaLocation=
"http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-2.1.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">https://stackoverflow.com/questions/12636729
复制相似问题