2012-08-13 19 views

回答

4

看一看的official spring batch documentation for itemReader

public interface ItemReader<T> { 

    T read() throws Exception, UnexpectedInputException, ParseException; 

} 
// so it is as easy as 
public class ReturnsListReader implements ItemReader<List<?>> { 
    public List<?> read() throws Exception { 
     // ... reader logic 
    } 
} 

處理器的工作原理相同

public class FooProcessor implements ItemProcessor<List<?>, List<?>> { 

    @Override 
    public List<?> process(List<?> item) throws Exception { 
     // ... logic 
    } 

} 

,而不是返回一個列表,該處理器可以例如返回任何東西a字符串

public class FooProcessor implements ItemProcessor<List<?>, String> { 

    @Override 
    public String process(List<?> item) throws Exception { 
     // ... logic 
    } 

} 
+0

我已更新過時的鏈接。另外,我有一個使用'JdbcPagingItemReader'的工作代碼,我可以調整它以返回一個List對象嗎?請[看我的問題](http://stackoverflow.com/questions/39848744/location-and-usecase-for-aggregateitemreader) – 2016-10-04 09:36:52

+0

它看起來不可能使其工作只是「調整」,我建議你創建一個完整的這裏的問題在你的需求的stackoverflow – 2016-10-04 10:45:06

相關問題