I am a Spring newbie. I found that sometime we need to construct an object using runtime data, but fixed value is used in constructor inject of Spring. I know I could create a setter method and change the value with it, but I don’t think this an elegant solution. Could any one tell me how to do it?
Share
Generally for this my preference is to make a factory like so:
This can be configured in XML aswell (which I would generally recommend over annotations for wiring business services, but it’s a more presentable answer here to use annotations). So then at runtime: