Microservices for Java developers
By: Rafael Benevides
The microservice architectural approach reaches into the foundation of your organization, letting you build complex systems to adapt to rapidly changing competitive markets. Now in its second edition, this step-by-step guide introduces concepts like immutable delivery, and gets you started building distributed systems for managing microservices using Linux containers, Kubernetes, and three different Java frameworks: Spring Boot, Dropwizard, and WildFly Swarm.
This book explains how to:
Expose a service.
Configure at runtime.
Expose metrics and insight.
Call downstream services in a safe manner.
Introducing Springboot: a opinionated Javaframework
Once you’ve installed the CLI tools, you should be able to check the version of Spring you have:
$ spring --version
Spring CLI v2.1.1.RELEASE
If you can see a version for your installation of the CLI, congrats! Now navigate to the directory where you want to host your examples from the report and run the following command:
$ spring init --build maven --groupId com.redhat.examples \ --version 1.0 --java-version 1.8 --dependencies web \ --name hello-springboot hello-springboot
After running this command, you should have a directory named hello-springboot with a complete Spring Boot application. If you run the command and end up with a demo.zip, then just unzip it and continue. Let’s take a quick look at what those command-line options are:
The build management tool we want to use. maven and gradle are the two valid options at this time.
The groupId to use in our Maven coordinates for our pom.xml. Unfortunately this does not properly extend to the Java package names that get created; these need to be modified by hand.
The version of our application. This will be used in later iterations, so set to 1.0.
The build compiler version for the JDK.
This is an interesting parameter; we can specify fully baked sets of dependencies for doing common types of development. For example, web will set up Spring MVC and embed an internal servlet engine (Tomcat by default, Jetty and Undertow as options). Other convenient dependency bundles/starters include jpa, security, and cassandra).