In general, most of the beans in the spring container are single-instance, so it is generally not necessary to specify a name for the bean through the Value property of the annotation @repository, @Service, @Component, etc. There is no need to use @qualifier to inject by name.
@Autowired are used in the following ways:
Labeling a class variable
@Autowired
Private Logdao Logdao;
Labeling A class method
To label a collection class (a property of a class)
@Autowired
Private list<plugin> plugins;
@Autowired
@Qualifier ("Testing")
Private Foodao Foodao;
Foodao corresponding Beanid is not necessarily foodao, there may be other.
Foodao has two implementation classes: Stubfoodao and Wjfoodao, see below
@Qualifier ("okdahello")
Private Foodao Foodao;
The Okdahello above can correspond to
@Repository ("Okdahello")
@Qualifier ("Testing")
public class Wjfoodao implements Foodao
can also correspond to
@Repository
@Qualifier ("Testing")
@Qualifier ("Okdahello")
public class Wjfoodao implements Foodao
@Qualifier ("Okdahello") or @Repository ("Okdahello") is all OK
@Repository ("Okdahello") can change Beanid.
Spring 3.0 It's such a simple reading note.