Spring Applications
Exercise: Todo REST Service
- 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.
- Modify the signature of the following methods:
addTodo - replace the parameters by a DTO TodoDto
updateTodo - add an ID path variable
completeTodo - add an ID path variable and a DTO CompletionDto
- Implement an exception handler that returns the error status 404 and a problem detail if the
TodoNotFoundException is thrown.
- Set the
spring.mvc.problemdetails.enabled application property to enable general support for problem details.
- Use the Postman utility to send HTTP requests the REST service.
Solution