Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java spring批处理ItemProcessorAdapter如何将多个参数传递给targetMethod?_Java_Spring_Spring Batch - Fatal编程技术网

Java spring批处理ItemProcessorAdapter如何将多个参数传递给targetMethod?

Java spring批处理ItemProcessorAdapter如何将多个参数传递给targetMethod?,java,spring,spring-batch,Java,Spring,Spring Batch,下面是我的ItemProcessor bean,我正在实现ItemProcessor接口。它工作得很好,但是 <beans:bean id="myItemProcessor" class="com.st.foundation.MyItemProcessor" p:id="#{jobParameters[date]}" p:type="my-type" scope="step" /> 我想将许多这样的bean组合到单个pojo中,并

下面是我的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>

福
酒吧
由此

但是我得到了“cvc complex type.2.4.c:匹配的通配符是严格的,但是找不到元素'value'的声明。”

接受对象数组作为参数;此数组的值用作参数,因此:

尝试用逗号分隔值

“p:arguments=“{jobParameters[date]},param2,param3”

或不带p命名空间设施:

<property name="arguments">
  <list>
    <value>{jobParameters[date]}</value>
    <value>param2</value>
    <value>param3</value>
  </list>
</property>

{作业参数[日期]}
参数2
param3
这对我很有效

<util:list id="myList" value-type="java.lang.String"
    scope="step">
    <beans:value>value1</beans:value>
    <beans:value>value2</beans:value>
</util:list>

价值1
价值2

尝试用逗号分隔,但无效。获取错误“目标类必须声明具有匹配名称和参数类型的方法”在
myItemProcessor
bean中缺少#before
{jobParameters[date]}