
@RestController("userControllerV1") @RequestMapping("/api/v1/users") public class UserController {
@GetMapping("/me") @ApiOperation("查询用户详情") @PreAuthorize("hasAuthority('ROLE_USER')") public User getDetails(Authentication authentication) { if (logger.isDebugEnabled()) { logger.debug("Principal class: {}", authentication.getClass()); } return (User) authentication.getPrincipal(); } }
一旦去掉 @PreAuthorize 注解就能访问到,否则授权后直接 404
1 johnniang OP global-method-enable 已经设置为 true 了 |
2 letitbesqzr 2017-12-12 11:20:32 +08:00 你看看是不是因为被拦截下来没权限 跳转到一个"未授页面" 那个"未授页面" 是 404 |
3 johnniang OP @letitbesqzr 在启动日志里面直接没有这个 /api/v1/users 这个 API 了,而且获取了 token 访问也没有结果,其他的 API 没有问题。其次,Swagger-ui 里面自然也没有这个 API。 |
4 johnniang OP up |
5 johnniang OP @letitbesqzr 搞定了,因为 Java 代理的原因 |
6 jiangydev 2019-04-28 18:09:20 +08:00 @johnniang 题主,你好,我也遇到了同样的问题,加了 @PreAuthorize 的接口就不初始化,请问你是怎么解决的? |
7 jiangydev 2019-04-28 23:20:01 +08:00 已解决 |