shiro @RequiresRoles 和 @@RequiresPermissions 注解失效问题
Posted zwb1
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了shiro @RequiresRoles 和 @@RequiresPermissions 注解失效问题相关的知识,希望对你有一定的参考价值。
需要配置以下三个bean
@Bean public LifecycleBeanPostProcessor lifecycleBeanPostProcessor(){ return new LifecycleBeanPostProcessor(); } @Bean public DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator(){ DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator = new DefaultAdvisorAutoProxyCreator(); defaultAdvisorAutoProxyCreator.setProxyTargetClass(true); return defaultAdvisorAutoProxyCreator; } @Bean public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(@Autowired DefaultWebSecurityManager securityManager) { AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor = new AuthorizationAttributeSourceAdvisor(); authorizationAttributeSourceAdvisor.setSecurityManager(securityManager); return authorizationAttributeSourceAdvisor; }
否则的话只能采用 subject.hasRole() 等代码的方式才能触发 Realm中的授权方法
以上是关于shiro @RequiresRoles 和 @@RequiresPermissions 注解失效问题的主要内容,如果未能解决你的问题,请参考以下文章