Configuration Spring Batch Bean #4440
Replies: 3 comments 5 replies
-
Can you please share a sample code that shows the duplication you want to refactor and the issue with the step-scoped bean? This would help us understand the problem clearly and help you efficiently. Thank you. |
Beta Was this translation helpful? Give feedback.
-
Thank you for the feedback. If I understand correctly, the product in this example is Moreover, are the DTOs similar or is there a DTO type per product? This is important to generify expressions like For step-scoped beans, there is a way to generate them dynamically with |
Beta Was this translation helpful? Give feedback.
-
I understand that the difficulty comes from step-scoped beans to get job parameters. As mentioned previously, if you can share a github repo with a minimal example with the duplication in place, then I can try to see if we could refactor it with an abstract class that users can extend and provide only the SQL query and its arguments. |
Beta Was this translation helpful? Give feedback.
-
Hello, I am currently optimizing the code for a historical project that uses Spring batch. The logic is that each product has a job, step, listener, reader, processor, and writer. These are all fine, but there are over 20 products in the historical project, which has caused code redundancy in many places for these classes. I am considering making them configurable, with the aim of automatically creating beans by filling in a small amount of necessary configurations. This spring theory is feasible, but I encountered a problem during the process, which is that the current project reader has the @ StepScope annotation, This bean was created only when the step was used, but now I am creating the bean through configuration. How can I manually register the bean that was created only when the step was used in the spring boot container? The effect of creating a new step after injection is ensured. I would be happy if you could solve my confusion
Beta Was this translation helpful? Give feedback.
All reactions