简体   繁体   English

Java Spring 批处理 - MultiResourceItemReader 不会在每次作业运行时读取新文件

[英]Java Spring Batch - MultiResourceItemReader not reading in new files every job run

I am working to get a spring batch application running that checks for new.txt files on a network drive on a scheduler.我正在努力让 spring 批处理应用程序运行,以检查调度程序上网络驱动器上的 new.txt 文件。 The intention is to read in those.txt files, grab the information off of them, process them, and then delete the original.txt file that was read.目的是读取那些.txt 文件,从中获取信息,处理它们,然后删除读取的 original.txt 文件。 The issue I'm running into is that it keeps reading the same resource even after the resource is deleted.我遇到的问题是,即使在资源被删除后,它也会继续读取相同的资源。

Subsequently this causes the next job to use the same exact resource again.随后,这会导致下一个作业再次使用相同的确切资源。 Something else I noticed was that it reads in the files before the first job even runs.我注意到的另一件事是,它甚至在第一个作业运行之前就读取了文件。

Am I doing something fundamentally wrong with spring batch?我对 spring 批次做一些根本性的错误吗? Is it not possible to do something like this: multiResourceItemReader.setResources(getNetworkFiles())不可能做这样的事情: multiResourceItemReader.setResources(getNetworkFiles())

So that every job it goes and reads in the files from the network drive?所以它执行的每项工作并从网络驱动器中读取文件?

Any help is greatly appreciated.任何帮助是极大的赞赏。

As it turns out, the getNetworkFiles() call I mentioned was annotated as a @Bean and it turns out it should not have been.事实证明,我提到的getNetworkFiles()调用被注释为 @Bean,事实证明它不应该是。 Removing that got it to re-read from the network drive directory.删除它可以从网络驱动器目录中重新读取。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Spring 使用MultiResourceItemReader 和使用ItemReadListener 批量读取文件 - Spring batch reading files with MultiResourceItemReader and using ItemReadListener 在Spring Batch中解密后通过MultiResourceItemReader读取文件 - Reading Files thru MultiResourceItemReader after de-cryption in Spring Batch Spring批处理MultiResourceItemReader-仅用于合并文件? - Spring batch MultiResourceItemReader - only used for combining files? 如何使用 spring-batch 和 MultiResourceItemReader 读取文件夹中的所有文件? - How to read all files in a folder with spring-batch and MultiResourceItemReader? 每个 spring 批处理作业运行中传递的参数相同 - Same parameters passed in every spring batch job run 每个资源的Spring Batch MultiResourceItemReader块提交 - Spring Batch MultiResourceItemReader Chunk Commit Per Resource 在 spring 批处理中,我们如何将处理后的文件移动到另一个文件夹,我正在使用 MultiResourceItemReader 和块处理 - In spring batch how can we move the processed files to another folder, I am using MultiResourceItemReader and chunk processing Spring 引导批处理 MultiResourceItemReader:如何使用 @Value() 从 jar 位置读取文件 - Spring boot batch MultiResourceItemReader: how to read files using @Value() from jar location Java EE 7批处理API-MultiResourceItemReader对应项 - Java EE 7 Batch API - MultiResourceItemReader counterpart 以编程方式运行Spring Batch Job? - Run Spring Batch Job programmatically?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM