【发布时间】:2014-04-29 12:10:31
【问题描述】:
下面是我的 ItemProcessor bean,我正在实现 ItemProcessor 接口。它工作正常,但
<beans:bean id="myItemProcessor"
class="com.st.foundation.MyItemProcessor"
p:id="#{jobParameters[date]}" p:type="my-type"
scope="step" />
我想将许多这样的 bean 组合成一个 pojo 并使用 ItemProcessorAdapter。
<beans:bean id="myItemProcessor"
class="org.springframework.batch.item.adapter.ItemProcessorAdapter"
p:targetObject-ref="myObject" p:targetMethod="myMethod"
p:arguments="{jobParameters[date]}" scope="step" />
但是我的 targetMethod 有多个参数(类型参数和 id)。如何将多个参数传递给适配器,因为它只有 p:arguments 参数?
我尝试用逗号分隔参数,但它不起作用。收到错误“目标类必须声明具有匹配名称和参数类型的方法”。
我也尝试过使用
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/batch"
xmlns:beans="http://www.springframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:file="http://www.springframework.org/schema/integration/file"
xmlns:integration="http://www.springframework.org/schema/integration"
xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/file http://www.springframework.org/schema/integration/file/spring-integration-file.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-2.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
<util:list id="myList" value-type="java.lang.String">
<value>foo</value>
<value>bar</value>
</util:list>
来自这个How to define a List bean in Spring?
但我得到“cvc-complex-type.2.4.c:匹配的通配符是严格的,但找不到元素'value'的声明。”
【问题讨论】:
标签: java spring spring-batch