2

我使用 ClassifierCompositItemWriter 的以下作业配置文件在标题中说明错误。为什么找不到 BackToBackPatternClassifier?我对此真的很陌生。

我正在使用 - Spring-core version 3.2.2.RELEASE - Spring batch version 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>
4

2 回答 2

4

我刚刚遇到了类似的问题,发现我必须将 Classifier 的包从

org.springframework.batch.classify.BackToBackPatternClassifier

org.springframework.classify.BackToBackPatternClassifier

即删除批次

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

于 2014-04-24T07:12:51.473 回答
1

BackToBackPatternClassifier(and Classifier) 被定义为spring-retry模块,可能您需要在类路径中包含它的 jar(我现在无法检查,但最新版本是spring-retry-1.0.2.RELEASE

于 2013-10-03T21:30:54.280 回答