This is happening because you are missing a FieldSetMapper
to map the content of the list you are seeing to the first and only element you want.
public class MyFieldSetMapper implements FieldSetMapper<String> {
@Override
public String mapFieldSet(FieldSet fieldSet) throws BindException {
String myItem = fieldSet.readString(0);
return myItem;
}
}
and in the XML config use the DefaultLineMapper
that is expecting a FieldSetMapper
:
<bean name="sampleLineMapper"
class="org.springframework.batch.item.file.mapping.DefaultLineMapper">
<property name="fieldSetMapper" ref="sampleMapper" />
<property name="lineTokenizer" ref="sampleLineTokenizer" />
</bean>
<bean name="sampleLineTokenizer" class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer" />
<bean name="sampleMapper" class="path.to.MyFieldSetMapper" />