0

异常没有达到onWriteError我的方法ItemWriteListener

public class KeywordsListener implements ItemWriteListener<ClipKeywords> {
    @Override
    public void onWriteError(Exception exception, List<? extends ClipKeywords> items) {
        for (ClipKeywords item : items) {
            log.info(item.getPhoneNum() + item.getKeyword());
        }
    }
}

@Bean
public KeywordsListener keywordsListener() {
    return new KeywordsListener();
}   

@Bean
    public Step step1() {
        return stepBuilderFactory.get("step1").<ClipKeywords, ClipKeywords> chunk(1).reader(reader(null))
                .processor(processor()).writer(writer()).faultTolerant().listener(keywordsListener()).build();

    }

构建.gradle

compile(group: 'org.springframework.boot', name: 'spring-boot-starter', version:'1.5.2.RELEASE') {
exclude(module: 'commons-logging')
    }
    compile group: 'org.bouncycastle', name: 'bcprov-jdk15on', version:'1.47'
    compile group: 'com.googlecode.json-simple', name: 'json-simple', version:'1.1.1'
    compile group: 'org.springframework.boot', name: 'spring-boot-starter-batch', version:'1.5.2.RELEASE'
    compile group: 'org.springframework.boot', name: 'spring-boot-starter-aop', version:'1.5.2.RELEASE'
    compile group:'org.springframework.boot', name:'spring-boot-starter-data-mongodb'

有人可以帮帮我吗?

4

0 回答 0