1.将prePostEnabled设置为true:@EnableGlobalMethodSecurity(prePostEnabled=true)
2.如果还是不起作用查看是否缺少aop依赖(小编当时不起作用就是缺少这个依赖):
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
本文介绍了如何在Spring Boot应用中配置GlobalMethodSecurity以启用预授权(@PreAuthorize)和后授权(@PostAuthorize)功能。当启用该功能后,系统将根据注解检查权限。若遇到问题,可能需要检查是否已引入了spring-boot-starter-aop依赖,该依赖对于AOP代理是必需的。
1.将prePostEnabled设置为true:@EnableGlobalMethodSecurity(prePostEnabled=true)
2.如果还是不起作用查看是否缺少aop依赖(小编当时不起作用就是缺少这个依赖):
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
789
3711