title: Spring @Qualifier value at runtime
body: <p>Is it possible to assign @Qualifier value at runtime. Let's say I have two beans of same type and a class with dependency injection</p>
  
  <pre><code>  &lt;bean id="typeA" class="com.debopam.test.Type"&gt;
           &lt;property name="typevalue" value="Export" /&gt;
      &lt;/bean&gt;
      &lt;bean id="typeB" class="com.debopam.test.Type"&gt;
           &lt;property name="typevalue" value="Import" /&gt;
      &lt;/bean&gt;
  
      public class Product {
      private Integer price;
      private String name;
  
      @Autowired
      @Qualifier("typeB")
      private Type type;
  
      public Integer getPrice() {
          return price;
      }
  
      public void setPrice(Integer price) {
          this.price = price;
      }
  
      public Type getType() {
          return type;
      }
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  }
  </code></pre>
  
  <p>Is there any way to define type in Product class in runtime instead of hard coding/specifying the value? If yes could you please post some code, otherwise is it advisable to use ApplicationContext.getBean("bean name") to load the bean at runtime?</p>