简体   繁体   English

如何在 Spring 批处理中使用 ResourceItemReader

[英]How do I use ResourceItemReader in Spring Batch

I'm new to Spring Batch and I need to create a custom reader using ResourceItemReader to get only resources names from.xml and.pdf files and pass to a class that represents them. I'm new to Spring Batch and I need to create a custom reader using ResourceItemReader to get only resources names from.xml and.pdf files and pass to a class that represents them.

For example:例如:

CustomReader read -> C:\teste\teste.xml, C:\teste\teste.pdf -> Populate in Class Domain their resources. CustomReader read -> C:\teste\teste.xml, C:\teste\teste.pdf -> Populate in Class Domain their resources.

Remering that I don't need to open the file, just get the resources. Remering我不需要打开文件,只需获取资源即可。

Any idea how I could do?知道我该怎么做吗?

Thanks!!谢谢!!

I need to create a custom reader using ResourceItemReader to get only resources names from.xml and.pdf files我需要使用 ResourceItemReader 创建一个自定义阅读器,以便仅从.xml 和.pdf 文件中获取资源名称

You don't need a custom reader for that.您不需要自定义阅读器。 You can filter resources and pass only the ones you want to the reader:您可以过滤资源并仅将您想要的资源传递给读者:

Resource[] resources = .. // create an array of only pdf and xml resources
ResourcesItemReader reader = new ResourcesItemReader();
reader.setRresources(resources);

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM