如何修复java.lang.ClassNotFoundException:org.springframework.batch.classify.BackToBackPatternClassifier

时间:2013-10-03 18:27:40

标签: spring-batch

我使用以下作业配置文件和ClassifierCompositItemWriter在Title中声明了错误。为什么找不到BackToBackPatternClassifier?我真的很陌生。

我正在使用   - Spring-core版本3.2.2.RELEASE   - Spring批量版本2.2.0.RELEASE

  

<bean id="domain" class="com.my.OneData" />

<job id="readAsString" xmlns="http://www.springframework.org/schema/batch">
    <step id="step1">
        <tasklet>
            <chunk reader="theItemReader" writer="compositeWriter"
                commit-interval="1" />
        </tasklet>
    </step>
</job>

<bean id="theItemReader" class="org.springframework.batch.item.file.FlatFileItemReader">
    <property name="resource" value="file:csv/inputs/ad_usage_sample.csv" />
    <property name="linesToSkip" value="1"></property>
    <property name="lineMapper">
        <bean
            class="org.springframework.batch.item.file.mapping.PassThroughLineMapper">
        </bean>
    </property>
</bean>

<bean id="compositeWriter"
    class="org.springframework.batch.item.support.ClassifierCompositeItemWriter">
    <property name="classifier">
        <bean
            class="org.springframework.batch.classify.BackToBackPatternClassifier">
            <property name="routerDelegate">
                <bean class="com.my.LineClassifier" />
            </property>
            <property name="matcherMap">
                <map>
                    <entry key="abc" value-ref="fileItemWriter1" />
                    <entry key="xyz" value-ref="fileItemWriter2" />
                </map>
            </property>
        </bean>
    </property>
</bean>

<bean id="fileItemWriter1" class="org.springframework.batch.item.file.FlatFileItemWriter">
    <property name="resource" value="file:csv/outputs/oneLouderOutput3.csv" />
    <property name="appendAllowed" value="true" />
    <property name="lineAggregator">
        <bean
    class="org.springframework.batch.item.file.transform.DelimitedLineAggregator">
            <property name="delimiter" value="," />
        </bean>
    </property>
</bean>

<bean id="fileItemWriter2" class="org.springframework.batch.item.file.FlatFileItemWriter">
    <property name="resource" value="file:csv/outputs/oneLouderOutput3.csv" />
    <property name="appendAllowed" value="true" />
    <property name="lineAggregator">
        <bean
    class="org.springframework.batch.item.file.transform.DelimitedLineAggregator">
            <property name="delimiter" value="," />
        </bean>
    </property>
</bean>

2 个答案:

答案 0 :(得分:3)

我遇到了类似的问题,发现我必须从

更改分类器的包
org.springframework.batch.classify.BackToBackPatternClassifier

org.springframework.classify.BackToBackPatternClassifier

即。删除批次

我也在使用spring-retry-1.0.3.RELEASE.jar

答案 1 :(得分:1)

BackToBackPatternClassifier(和Classifier)的定义是spring-retry模块,可能你需要在你的类路径中包含它的jar(我现在不能检查,但是最新的版本是{{ 1}})