C/C++教程

@RequiresAuthentication或@RequiresPermissions不生效

本文主要是介绍@RequiresAuthentication或@RequiresPermissions不生效,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

如果@RequiresAuthentication和@RequiresPermissions不生效,可尝试在ShiroConfig中添加下面代码,开启Aop支持

 @Bean("lifecycleBeanPostProcessor")
    public LifecycleBeanPostProcessor lifecycleBeanPostProcessor() {
        return new LifecycleBeanPostProcessor();
    }

@Bean
@DependsOn({"lifecycleBeanPostProcessor"})
public DefaultAdvisorAutoProxyCreator advisorAutoProxyCreator() {
    DefaultAdvisorAutoProxyCreator advisorAutoProxyCreator = new                 
                                                     DefaultAdvisorAutoProxyCreator();
    advisorAutoProxyCreator.setProxyTargetClass(true);
    return advisorAutoProxyCreator;
}

@Bean("authorizationAttributeSourceAdvisor")
public AuthorizationAttributeSourceAdvisor 
                  authorizationAttributeSourceAdvisor(SecurityManager securityManager) {
    AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor = new 
                                                  AuthorizationAttributeSourceAdvisor();
    authorizationAttributeSourceAdvisor.setSecurityManager(securityManager);
    return authorizationAttributeSourceAdvisor;
}

这篇关于@RequiresAuthentication或@RequiresPermissions不生效的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!