1

I want to fetch a bean based on string by using dependency injection. I want to find a way in which I can map strings into beans. I know standard java ways to do that such as using a hash-map but I want to do it the spring way. Here is my main logic:

if workflow key is LOGINWORKFLOW return LOGINWORKFLOW bean. How to achieve this in spring boot?

I don't want to use xml.

Approach:

I can autowire all of the beans in a single class and then add them in a hash map by using the @Postconstruct annotation

Fernando
  • 381
  • 1
  • 5
  • 20
  • Possible duplicate of [Inject spring bean dynamically](https://stackoverflow.com/questions/40105044/inject-spring-bean-dynamically) – Mohammed Housseyn Taleb Aug 05 '19 at 00:12
  • also [check](https://stackoverflow.com/questions/42909283/how-to-dynamically-inject-a-service-using-a-runtime-qualifier-variable/42985496#42985496) and [solution1](https://stackoverflow.com/a/40377675/4388228) – Mohammed Housseyn Taleb Aug 05 '19 at 00:15

0 Answers0