0

For example, I have 1000+ services, and each of them implements some interface AwesomeInterface.

My plan is to autowire the collection of such services into MainService's constructor so that I can use them afterward:

public MainService(@Autowired List<AwesomeInterface> services){
    this.services = services;
}

The question is: can I autowire so many services technically? I mean, is it enough memory, etc? I do not want to create all of them to test my theory :)

P.S. I believe that it may be not the best thing to autowire such a big amount of bins, however, I am still curious :)

I use SpringBoot, Java11

Lilia
  • 77
  • 1
  • 7
  • In your example, you are trying to Autowire an instance of List. Not sure if that 'll work. – Stultuske Oct 27 '22 at 05:50
  • @Stultuske, I am injecting all beans, that implement `AwesomeInterface` and collecting them to a list. It is working – Lilia Oct 27 '22 at 13:14

0 Answers0