0

I am starting with Spring-Boost and try to use an autowired/injected component.

How can I make a component that is autowired elsewere but gets a parameter in the constructor?

Is there a way I can set a parameter with AutoWired?

chris01
  • 10,921
  • 9
  • 54
  • 93
  • actually good question, in my opinion you just cant. It is discussed also here https://stackoverflow.com/questions/6739566/is-there-a-way-to-autowire-a-bean-that-requires-constructor-arguments So maybe factory pattern would be qua solution – Michal Drozd Oct 01 '20 at 11:42
  • If I get your question right, maybe it's an option to use a @ Configuration class, where you have a method with the @ Bean annotation - here you can initialize your bean with the parameters you like. – most_wanted Oct 02 '20 at 13:38

0 Answers0