我已将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怎么了?
答案 0 :(得分:0)
您错过了我添加"/register"
@PostMapping("/register")
@ResponseStatus(HttpStatus.CREATED)
public
ResponseEntity<Void> register(
@RequestBody final RegisterDto registerDTO
)