zoukankan      html  css  js  c++  java
  • springboot shiro开启注释

    shiroconfiguration中增加

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

    在controller中的方法前加上注解

    @RequiresPermissions("userInfo:test")
    

    若还没生效,应该是aop没起作用,

    解决方法一

    shiroconfiguration中增加

    @Bean
        @ConditionalOnMissingBean
        public DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator() {
            DefaultAdvisorAutoProxyCreator defaultAAP = new DefaultAdvisorAutoProxyCreator();
            defaultAAP.setProxyTargetClass(true);
            return defaultAAP;
        }
    

    解决方法二

    pom.xml中加入

    <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-aop</artifactId>
            </dependency>
    

    同时application.properties中补充

    spring.aop.proxy-target-class=true
    

      

  • 相关阅读:
    [CF864F]Cities Excursions
    [AGC012F]Prefix Median
    [TC-FindingFriends]Finding Friends
    [TC-HouseProtection]House Protection
    [CTSC2018]假面
    [CF877F]Ann and Books
    [CF509F]Progress Monitoring
    [CF735E/736C]Ostap and Tree
    CF611H New Year and Forgotten Tree
    CF538H Summer Dichotomy
  • 原文地址:https://www.cnblogs.com/tuifeideyouran/p/7696055.html
Copyright © 2011-2022 走看看