在Springboot环境中继承Shiro时,[email protected]
[email protected]("/list") @RequiresPermissions(value = { "进货单据查询" })
public Map<String,Object> list(PurchaseList purchaseList)throws Exception{
Map<String, Object> resultMap = new HashMap<>(); List<PurchaseList>
purchaseListList=purchaseListService.list(purchaseList, Direction.DESC,
"purchaseDate"); resultMap.put("rows", purchaseListList); return resultMap; }
解决方法:需要开启Shiro注解。在ShiroConfig类中添加如下代码。
    /** *
开启Shiro的注解([email protected],@RequiresPermissions),需借助SpringAOP扫描使用Shiro注解的类,并在必要时进行安全逻辑验证
*
配置以下两个bean(DefaultAdvisorAutoProxyCreator(可选)和AuthorizationAttributeSourceAdvisor)即可实现此功能
* @return */ @Bean @DependsOn({"lifecycleBeanPostProcessor"}) public
DefaultAdvisorAutoProxyCreator advisorAutoProxyCreator(){
DefaultAdvisorAutoProxyCreator advisorAutoProxyCreator = new
DefaultAdvisorAutoProxyCreator();
advisorAutoProxyCreator.setProxyTargetClass(true); return
advisorAutoProxyCreator; } @Bean public AuthorizationAttributeSourceAdvisor
authorizationAttributeSourceAdvisor(){ AuthorizationAttributeSourceAdvisor
authorizationAttributeSourceAdvisor = new
AuthorizationAttributeSourceAdvisor();
authorizationAttributeSourceAdvisor.setSecurityManager(securityManager());
return authorizationAttributeSourceAdvisor; }