我有兩個步驟春季批次+完成某個步驟
<batch:step id="parseXML" next="commitSQL">
<batch:tasklet>
<batch:chunk reader="bookListReader" writer="xmlBookListWriter" commit-interval="1"/>
</batch:tasklet>
</batch:step>
<batch:step id="commitSQL">
<batch:tasklet ref="databaseItemWriter"/>
</batch:step>
我沒有與任何代碼的問題,但步驟commitSQL
不執行可言,只有一步parseXML
被無限運行。
我的讀者代碼
@Override
public List<Book> read() throws Exception, UnexpectedInputException, ParseException,
NonTransientResourceException {
// TODO Auto-generated method stub
System.out.println("I am reading :) :)");
List<Book> bookList = new ArrayList<>();
bookList.add(new Book("Java","Cay","McGrall","1234"));
bookList.add(new Book("E Java","Cay","McGrall","1234"));
return bookList;
}
和作家代碼
private static void convertBookListToXML(List<? extends Book> books) throws IOException {
List<Book> bookList = getBookList(books);
try {
System.out.println("I am writer :) :)");
JAXBContext jaxbContext = JAXBContext.newInstance(Books.class);
Marshaller xmlMarshaller = jaxbContext.createMarshaller();
xmlMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
BufferedWriter writer = new BufferedWriter(new FileWriter(BOOK_FILE));
xmlMarshaller.marshal(new Books(bookList), writer);
writer.close();
} catch (JAXBException e) {
e.printStackTrace();
}
}
爲parseXML
,但我對commitSQL
代碼是不執行的。任何建議我怎麼會出來parseXML
並繼續commitSQL
請使用正確的標籤;這個問題與批處理文件的Windows.BAT批處理文件沒有任何關係! – Aacini
您必須從ItemReader.read()返回null來停止讀取過程 –
@LucaBassoRicci,您的選擇爲我工作 –