我正在尝试将Spring Batch 2.2.5与Java配置一起使用.这是我的配置:
@Configuration
@EnableBatchProcessing
public class JobConfiguration {
@Autowired
private JobBuilderFactory jobBuilder;
@Autowired
private StepBuilderFactory stepBuilder;
@Bean
@Autowired
public Job processDocumentsJob() {
return jobBuilder.get("processDocumentsJob")
.start(procesingStep())
.build();
}
@Bean
@Autowired
public Step procesingStep() {
CompositeItemProcessor<File, DocumentPackageFileMetadata> compositeProcessor = new CompositeItemProcessor<File, DocumentPackageFileMetadata>();
compositeProcessor.setDelegates(Lists.newArrayList(
documentPackageFileValidationProcessor(),
documentMetadataFileTransformer()
));
return stepBuilder.get("procesingStep")
.<File, DocumentPackageFileMetadata>chunk(1)
.reader(documentPackageFileReader())
.processor(compositeProcessor)
.writer(documentMetadataFileMigrator())
.faultTolerant()
.skip(DocumentImportException.class)
.skipLimit(10)
.listener(stepExecutionListener())
.build();
}
....
}
Run Code Online (Sandbox Code Playgroud)
使用上面的配置,如果itemwriter(documentMetadataFileMigrator指向的bean)抛出'DocumentImportException',则不会跳过该异常.Spring Batch实际上会再次重试相同的输入.即它将对'documentPackageFileValidationProcessor'使用相同的输入.
但是,如果我将itemwriter中的逻辑移动到itemprocessor中:
@Bean
@Autowired
public Step procesingStep() {
CompositeItemProcessor<File, DocumentPackageFileMetadata> compositeProcessor = new CompositeItemProcessor<File, DocumentPackageFileMetadata>();
compositeProcessor.setDelegates(Lists.newArrayList(
documentPackageFileValidationProcessor(),
documentMetadataFileTransformer(),
documentMetadataFileMigratorAsProcessor() …Run Code Online (Sandbox Code Playgroud) 道歉,如果之前已经被问过,但我试过谷歌搜索主题没有任何好结果.基本上我正在尝试找到Google小部件的替代品,谷歌决定弃用它.到目前为止,我有以下候选人:
ViewPager.不幸的是(据我所知),您一次只能显示一个视图.我知道有人在此发布了一个解决方法:https://gist.github.com/devunwired/8cbe094bb7a783e37ad1.但我对这种方法有疑问.在我的手机上,显示了三个图像(水平).最左边和最右边是静态的,而中间的是可滚动的(就像ViewPager应该做的那样).即当我滚动ViewPager时,最左侧和最右侧的图像不会滚动.所以我必须拒绝这个解决方案.
网格视图.看起来不错,但看起来GridView设计为可水平和垂直滚动.我只想要一行,然后水平滚动.据我所知,Gallery并没有考虑到这一点.
HorizontalScrollView.谷歌在Javadocs中建议的另一个(除了ViewPager).看起来好像是一个好用的,但是...如果我理解正确,使用这种方法所有内容都将被预先实例化.没有延迟加载..
所以我在这里很困惑.似乎最好的解决方案是使用ViewPager一次只有一个View(对于我想要的东西不合适),或者坚持使用Gallery.
人们怎么想?
提前致谢!