Spring 第 3 批,在 IBM JVM (BackToBackPatternClassifier) 上加载配置时出错

Spring batch 3, error at configuration load on IBM JVM (BackToBackPatternClassifier)

使用 IBM 的 JRE 1.7 启动 spring 批处理作业时出现错误。

Spring批量版本为3.0.7,Spring版本为4.3.5

Oracle JDK 1.7 不会发生此错误。 当我加载我的 Spring 批处理 XML 配置时,它会出现,甚至在作业开始之前。 这个问题出现在我升级Spring Batch and Spring : org.springframework.batch.classify.BackToBackPatternClassifier from Spring Batch become org.springframework.classify.BackToBackPatternClassifier (in Spring Retry)

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'classifierCcsb01Writer' defined in class path resource [com/bob/batch/spring/configuration/jobs-configuration.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'routerDelegate' threw exception; nested exception is java.lang.IllegalStateException: More than one non-void public method detected with single argument.
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1523)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1231)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:551)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351)
    ... 26 more
Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'routerDelegate' threw exception; nested exception is java.lang.IllegalStateException: More than one non-void public method detected with single argument.
    at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:121)
    at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:75)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1519)

职位-configuration.xml:

<bean id="ItemWriter"
        class="org.springframework.batch.item.support.ClassifierCompositeItemWriter">
        <property name="classifier" ref="classifierCcsb01Writer" />
    </bean>

    <bean id="classifierCcsb01Writer"
        class="org.springframework.classify.BackToBackPatternClassifier">
        <property name="routerDelegate">
            <bean
                class="com.bob.batch.spring.writers.ClassifierCcsb01Writer" />
        </property>
        <property name="matcherMap">
            <map>
                <entry key="create" value-ref="ccsb01Writer" />
                <entry key="ko" value-ref="ccsb01ErrorWriter" />
            </map>
        </property>
    </bean>

和分类器Ccsb01Writer:

package com.bob.batch.spring.writers;

import org.springframework.batch.support.annotation.Classifier;

import com.bob.batch.spring.bean.RoutingBean;

public class ClassifierCcsb01Writer {

    @Classifier
    public String classify(RoutingBean routingBean) {
        return routingBean.getType();
    }

}

只是包导入错误... 从 SpringBatch V3 开始,Classifier 必须从包中导入:

  • org.springframework.classify.annotation.Classifier

而不是以前的 (SpringBatch V2)

  • org.springframework.batch.support.annotation.Classifier

包导入修正后,一切正常!

此致, 大.