0

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

Spring Batch 版本是 3.0.7,Spring 版本是 4.3.5

Oracle JDK 1.7 不会发生此错误。它出现在我加载我的 Spring Batch XML 配置时,jobs-configuration.xml 甚至在工作开始之前。这个问题出现在我升级 Spring Batch 和 Spring 之后: org.springframework.batch.classify.BackToBackPatternClassifier from Spring Batch 变成 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$1.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)

工作配置.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>

和 ClassifierCcsb01Writer:

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();
    }

}
4

1 回答 1

1

这只是一个包导入错误...由于 SpringBatch V3,必须从包中导入分类器:

  • org.springframework.classify.annotation.Classifier

而不是以前的(SpringBatch V2)

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

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

问候,大。

于 2017-01-05T13:58:29.870 回答