Reputation: 4402
I have some Spring Beans of a specific type but with different names:
@Bean public Car audi() { .. }
@Bean public Car mercedes() { .. }
@Bean public Car honda() { .. }
Now I can autowire all of them with:
@Autowired List<Car> cars;
With this I get all Car-objects.
Is it possible to get also the bean names somehow?
Upvotes: 6
Views: 2153
Reputation: 4402
M. Deinums comment had the correct solution
@Autowired Map<String, Car> carsAndNames;
Upvotes: 4