I am using
<context:component-scan base-package="com.package.dao"/> (Spring 3)
and in my controllers with @Autowired will retrieve automatically the DAO I need. That's perfect and works. The problem is when I need more than one DAO manager. How can I do? I tried with @Qualifier but I am not sure about the name of the da开发者_运维技巧o-manager. className doesn't work
someone can help me?
Thank you!
See in the spring documentation:
@Autowired is fundamentally about type-driven injection with optional semantic qualifiers. This means that qualifier values, even when using the bean name fallback, always have narrowing semantics within the set of type matches; they do not semantically express a reference to a unique bean id
...
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, prefer 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.
Use @Resource instead, see here.
精彩评论