我已经将Swagger添加到项目中,并且它可以https://zapodaj.net/217c8a0dcf348.png.html运行。添加控制器后
@RestController(value = "/register")
public class RegisterRestController {
...
@PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.CREATED)
public
ResponseEntity<Void> register(
@RequestBody final RegisterDto registerDTO
) {
this.userService.createUser(registerDTO);
final HttpHeaders httpHeaders = new HttpHeaders();
return new ResponseEntity<>(httpHeaders, HttpStatus.CREATED);
}
}
Swagger UI停止工作https://zapodaj.net/c60c3029b0905.png.html。踢球
"error": "Method Not Allowed",
"message": "Request method 'GET' not supported",
"status": "405"
我在stackoverflow上找到了类似的主题,但我不知道他如何帮助我。 Swagger是怎么回事?
最佳答案
您缺少对我添加的"/register"
方法的映射
@PostMapping("/register")
@ResponseStatus(HttpStatus.CREATED)
public
ResponseEntity<Void> register(
@RequestBody final RegisterDto registerDTO
)