Spring Batch文件阅读器无法读取文件中的所有行

时间:2018-01-25 06:13:31

标签: java spring-batch filereader

我使用Spring Batch处理上传的文件。当我尝试读取具有30K记录的文件时,它只读取18k行并进行处理。它没有考虑剩下的记录。这些是在我的配置中声明的bean。



<job id="JobSeq1" restartable="true" parent="ParentJob">
		<step id="DelegateTask" next = "FileParser" >
			<tasklet ref = "JobTask">
				<listeners>
						<listener ref="PromotionListener" />
				</listeners>
			</tasklet>	
		</step>
		
		<step id="FileParser" next = "FileStaggingProcessor" >
			<tasklet ref = "FileParserTask">
				<listeners>
						<listener ref="PromotionListener" />
				</listeners>
			</tasklet>	
		</step>
		
		<step id="FileStaggingProcessor">
			<tasklet>
				<chunk reader="FileReader" writer="FileWriter"
					commit-interval="100" skip-limit="100">
						<skippable-exception-classes>
							<include class="org.springframework.batch.item.file.FlatFileParseException" />
						</skippable-exception-classes>	
				</chunk>
			</tasklet>
		</step>
		</job>
		
		<beans:bean id="FileReader"
		class="org.com.myProj.FileReader">	
			<beans:property name="linesToSkip" value="1"/> 
			<beans:property name="lineMapper">
			<beans:bean
				class="org.springframework.batch.item.file.mapping.DefaultLineMapper">
			
				<beans:property name="lineTokenizer">
					<beans:bean
						class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer">
						<beans:property name="delimiter" value="," />	
					</beans:bean>
				</beans:property>
				<beans:property name="fieldSetMapper" ref="myMapper">
				</beans:property>
			</beans:bean>
		</beans:property>
		<beans:property name="saveState" value="true"></beans:property>				
	</beans:bean>
		
&#13;
&#13;
&#13;

读者看起来像

&#13;
&#13;
public class FileReader extends FlatFileItemReader<CombMappingVO> implements 
StepExecutionListener{

@Override
public void beforeStep(StepExecution stepExecution) throws 
StepListenerFailedException{
if(!inputFilePath.isEmpty() && !ObjectValidator.isObjectNull(inputFilePath))
    {
	String csvInputFilePath = new Helper().convert2CSV(inputFilePath);
	super.setResource(new FileSystemResource(csvInputFilePath));
	}
 }
}
&#13;
&#13;
&#13;

我使用映射器将文件数据加载到临时表中,我可以看到确切的18K记录。有没有办法确定问题所在?

0 个答案:

没有答案