Creating microservice consumers

To consume this RESTful microservice, let's create a consumer web application. This web application will consume RESTful service endpoints. Spring provides several ways to consume microservices, but in this web application, we will use the RestTemplate class. This RestTemplate class allows you to send HTTP requests to a RESTful server and fetch data in a number of formats, such as JSON and XML.

The format of data depends on the presence of marshalling classes on the classpath of the web application. The web application will support the JSON format if Jackson JARS are present in the classpath. Similarly, it will support the XML format if JAXB JARS are present in the classpath.

In this web application, the

Get Mastering Spring Boot 2.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.