Spring Web
Exercise: Todo REST Service
-
Clone the GitLab repository Todo and copy the application.
-
Remove the client from the todo application and add the
spring-boot-starter-webmvc Maven dependency.
-
Rename the
TodoService class to TodoController and annotate it using Spring Web MVC annotations.
-
Replace the multiple parameters of the
addTodo method by a DTO TodoDto and add an ID path variable to the updateTodo method.
-
Implement an exception handler for the
TodoNotFoundException such that the error status 404 and a problem detail is returned when the exception is thrown.
-
Set the
spring.mvc.problemdetails.enabled application property to enable general support for problem details.
-
Use the Postman utility to send REST requests the web service.
Solution