Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Thank you for the extra details, it wasn't immediately obvious what you were trying to do.</p> <p>The <code>@Qualifier</code> annotation is not meant to be used in the same way as <code>@Resource</code>. When you specify the meta-data <code>&lt;qualifier&gt;</code> element, you are overwriting the identifier that would be used when resolving <code>@Qualifier</code>. In this case, the <code>&lt;qualifier&gt;</code> identifier <code>"secondaryFoo"</code> replaces the <code>&lt;bean&gt;</code> identifier <code>"anotherFoo"</code>. If you changed your declaration to</p> <pre><code>@Autowired @Qualifier(value = "secondaryFoo") private Foo foo; </code></pre> <p>It would be autowired correctly. However, you can still use </p> <pre><code>Foo anotherFoo = (Foo) applicationContext.getBean("anotherFoo"); </code></pre> <p>to get the <code>&lt;bean&gt;</code> with <code>id</code> <code>"anotherFoo"</code>. Although this would fail</p> <pre><code>Foo anotherFoo = (Foo) applicationContext.getBean("secondaryFoo"); </code></pre> <p>If you are looking for how to autowire based on a unique id, you should use <code>@Resource</code>. The <a href="http://docs.spring.io/spring/docs/3.2.x/spring-framework-reference/html/beans.html#beans-autowired-annotation-qualifiers" rel="nofollow">documentation</a> states:</p> <blockquote> <p>If you intend to express annotation-driven injection by name, do not primarily use @Autowired, even if is technically capable of referring to a bean name through @Qualifier values. Instead, use the JSR-250 @Resource annotation, which is semantically defined to identify a specific target component by its unique name, with the declared type being irrelevant for the matching process.</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload