@Autowired is injected by default by Bytype, but when the Bytype method finds multiple compliant beans, it is handled.
After some code testing, I found that autowired by default first by pressing Bytype, if found more than one bean, then, in accordance with the ByName method, if there are more than, then reported an exception.
Example:
@Autowired
Private Examusermapper Examusermapper; -Examusermapper is an interface
1. Spring first find a bean of type Examusermapper
2. If present and unique, OK;
3. If not unique, in the result set, look for a bean with name Examusermapper. Because the name of the bean is unique, it should be possible to determine if there is a bean that satisfies the requirement.
@Autowired can also manually specify ByName injection, using @qualifier tags, such as @Autowired () @Qualifier ("Basedao")
Because the name of the bean is unique, theoretically the byname will be faster, but spring defaults to injecting in Bytype, which makes me confused and not sure which one is really fast. Concrete to the actual application, the feeling is not very different, see everyone's habit
Note: The label of the @Resource (this annotation belongs to the Java EE) is injected by default in byname manner