public AuthRealm authRealm(@Qualifier("credentialMatcher")

来源:3-9 基于Apache Shiro权限管理Case实操-1

慕斯5332939

2018-05-29

@Qualifier("credentialMatcher") CredentialMatcher matcher)中前面不用加上这个@Autowired吗?还是这个@Qualifier("credentialMatcher") CredentialMatcher matcher)单独使用只能在shiro 中

写回答

1回答

Jimin

2018-05-29

你好,先推荐一篇讲解Spring注解的文章:

https://blog.csdn.net/zhengyang7754/article/details/62216024

这里介绍了@Autowired 和 @Qualifier。

回过头说一下为什么@Qualifier("credentialMatcher") CredentialMatcher matcher)中前面不用加上这个@Autowired。因为这个类标识了@Configuration,对应的方法也使用了@Bean标识,@Configuration相当于之前spring bean定义里的xml中的<beans>标签,@Bean相当于xml中的<bean>标签。本身这里就做的是注入的事情,因此不需要再声明一次@Autowired去注入了。如果你对源码感兴趣,也可以学习一下这里的源码,比如 https://blog.csdn.net/liaokailin/article/details/49107209

祝你学习愉快~

0
1
慕斯5332939
非常感谢!
2018-05-29
共1条回复

Java开发企业级权限管理系统

源于企业真实Java项目,涉及大量高级技巧,覆盖权限管理开发技术

2261 学习 · 1347 问题

查看课程