1 回答
TA贡献1820条经验 获得超2个赞
您可以尝试以下操作:
@Bean
LineMapper<List<Engine>> lineMapper() {
return new LineMapper<List<Engine>>() {
@Override
public <List<Engine>> mapLine(String line, int lineNum) throws Exception {
String[] tokens = line.split(";");
if (tokens.length < 1) {
throw new DataIntegrityViolationException("Expecting at least one token in input line: " + line);
}
List<Engine> data = new ArrayList<Engine>;
for (String token : tokens) {
data.add(Engine.of(token));
}
return data;
}
};
}
....
FlatFileItemReader<List<Engine>> itemReader = new FlatFileItemReader<>();
itemReader.setLineMapper(lineMapper);
添加回答
举报