shiro 注解不生效

springboot集成shiro时,使用@RequiresRoles注解不生效。
shiro @RequiresRoles底层使用springaop技术:
1.@RequiresRoles修饰service层接口(接口代理)
如不生效需引入aspectj包:

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

2.@RequiresRoles修饰controller层接口(类代理)
如不生效,请查看是否使用this调用了controller层方法。
因使用aop动态代理技术,因此不能直接使用this调用方法。可通过getBean获取运行时生成的动态代理对象。
搞了半天,记录下。给各位兄弟省点时间。。

猜你喜欢

转载自www.cnblogs.com/tswhq/p/11622745.html