我已经处理过这样的未经授权的异常
@ResponseStatus(value= HttpStatus.UNAUTHORIZED)
public class UnauthorizedException extends RuntimeException {
public UnauthorizedException(String message) {
super(message);
}
}
Run Code Online (Sandbox Code Playgroud)
但是当我抛出如下错误时
throw new UnauthorizedException("Invalid credentials");
Run Code Online (Sandbox Code Playgroud)
我在响应中收到错误消息为空,如下所示
{
"timestamp": "2020-05-27T13:44:58.032+00:00",
"status": 401,
"error": "Unauthorized",
"message": "",
"path": "/auth/register"
}
Run Code Online (Sandbox Code Playgroud)
我尝试使用,
throw new ResponseStatusException(HttpStatus.UNAUTHORIZED, "Invalid credentials");
Run Code Online (Sandbox Code Playgroud)
但结果还是一样。当我添加spring-boot-devtools依赖项时,我也按预期通过堆栈跟踪收到消息。我怎样才能解决这个问题?
Spring 版本:2.3.0 Java 版本:11.0
我找不到将BASE URL添加到的方法django rest swagger.我尝试添加
SWAGGER_SETTINGS = {
"base_path": 'localhost:62090/',
}
Run Code Online (Sandbox Code Playgroud)
到settings.py.但它不起作用.