springboot shiro open annotation

springboot shiro open annotation

added in shiro configuration

1
2
3
4
5
6
7
@Bean
     public  AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(SecurityManager securityManager) {
         AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor
             new  AuthorizationAttributeSourceAdvisor();
         authorizationAttributeSourceAdvisor.setSecurityManager(securityManager);
         return  authorizationAttributeSourceAdvisor;
     }

Annotate before the method in the controller

1
@RequiresPermissions ( "userInfo:test" )

If it does not take effect, it should be that aop does not work.

Solution one

added in shiro configuration

1
2
3
4
5
6
7
@Bean
     @ConditionalOnMissingBean
     public  DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator() {
         DefaultAdvisorAutoProxyCreator defaultAAP =  new  DefaultAdvisorAutoProxyCreator();
         defaultAAP.setProxyTargetClass( true );
         return  defaultAAP;
     }

Solution two

added to pom.xml

1
2
3
4
<dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-aop</artifactId>
         </dependency>

Also added in application.properties

1
spring.aop.proxy-target- class = true

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324801578&siteId=291194637