Spring Applications
Exercise: Todo REST Client
- Add the Maven dependencies
org.springframework:spring-web
, com.fasterxml.jackson.core:jackson-databind
and com.fasterxml.jackson.datatype:jackson-datatype-jsr310
to the todo application.
- Remove the repository and the JPA annotations from the
Todo
class and rename the TodoService
class into TodoProxy
.
- Use the Spring
RestClient
to implement the proxy methods which send REST requests to the web service (see API Documentation).
- In the
findTodo
and updateTodo
methods catch the HttpClientErrorException.NotFound
exception, get the problem detail from the response body and rethrow a TodoNotFoundException
.
Solution