Spring Applications

Exercise: Todo REST Service

  1. Remove the client from the todo application and add the spring-boot-starter-webmvc Maven dependency.
  2. Rename the TodoService class to TodoController and annotate it using Spring Web MVC annotations.
  3. 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
  4. Implement an exception handler that returns the error status 404 and a problem detail if the TodoNotFoundException is thrown.
  5. Set the spring.mvc.problemdetails.enabled application property to enable general support for problem details.
  6. Use the Postman utility to send HTTP requests the REST service.

Solution