@Autowired @Qualifier("userDao") to be used with

By default, @Autowired looks for a matching bean in the container by type matching. If there is only one matching bean, Spring injects it into the variable marked by @Autowired . If there is more than one matching bean in the container, the bean name can be qualified by the @Qualifier annotation. For example:
@Service
public class LoginService
{
@Autowired
@Qualifier ("userDao")
private UserDao userDao; //here
}
Assuming that there are two beans of type UserDao in the container, one named userDao and the other named otherUserDao search, then The bean injected "here" above is the userDao.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326679660&siteId=291194637