[英]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.