Spring注解@Qualifier、@Autowired、@Primary @Qualifier

@Qualifier

1, when a plurality of the interface implementation classes, and have been injected into the Spring container, is used @AutoWired byType, and these types are the same implementation class, should be used and @Qualifier explicitly specify the implementation class. Therefore, @ Qualifier is byName of.

2, for the implementation class can not declare names in parentheses after the @Compoment where you can specify the name of the new @Qualifier.

3, for the implementation class, removed name, plus @Primary , can be achieved. Means: @Primary default implementation class, without the use of @Qualifier explicitly specify that the implementation class.

Guess you like

Origin www.cnblogs.com/cathyqq/p/12374584.html