Summary

Java is a rich platform and there are numerous ways to achieve the same goal. This introductory chapter presented an opinionated view on the process of creating a Microservice from scratch. As a first step, the very basic process of general Java project creation was explained. We saw that both Java EE and Spring grow from the same Java roots. In general, as a consequence of the richness of the Java ecosystem, even the project-creation phase can be performed in various ways, not to mention the steps of actually implementing the Microservice. The approaches shown in this chapter are time-proven, universal, and most likely to be applied on a real project.

The Weather Microservice implemented with Java EE demonstrates its long-term focus on convention over configuration. Besides the actual Temperature resource, represented by a single class complemented with very few JAX-RS metadata annotations, there it was only one value configured. The value is the context path of the REST API within the Microservice, nothing more. RESTful resources implemented with JAX-RS are automatically discovered and integrated with the rest of Java EE's functionality. After the implementation phase, it was shown how Maven, the project management tool, can be used to build a thin Java Web Archive. With the Weather Microservice built and packaged into a WAR, we saw how a Microservice can be deployed and run by a single command using a Payara Micro instance.

A Spring-Framework-based implementation of the Weather Microservice was performed on the same roots. Creating the actual resource required only one class, complemented with some metadata in the form of Spring REST MVC annotations. The next series of steps aimed to explain how modern Spring Framework applications are built, packaged, and run in an opinionated way named Spring Boot. First, we looked at how simple it is to configure Maven to produce a Spring Boot Java Archive. We emphasized how Spring Boot's JAR can be simply executed, as it contains all the dependencies required, including the parts of a servlet container. Finally, we saw how to implement a class that contains an entry point to the Spring Boot Microservice. We explained how the convention-over-configuration approach has reached the Spring world and which configuration steps are being done for the developer automatically.

Both Java EE and Spring Framework are very rich platforms, each with unique strengths. This chapter showed you a minimalistic use case for both platforms. The world of Microservices brings with it many new ideas and possibilities. In the chapters to come, such possibilities will be revealed and demonstrated. In the next chapter, we will discuss how various Microservices would interact with each other.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.28.179