The example project is built with the tool Maven.5 The installation of the tool is described at The command mvn package in the directory microservice/microservice-demo can be used to download all dependent libraries from the Internet and to compile the application.

The configuration of the projects for Maven is saved in files named pom.xml. The example project has a Parent-POM in the directory microservice-demo. It contains the universal settings for all modules and in addition a list of the example project modules. Each microservice is such a module, and some infrastructure servers are modules as well. The individual modules have their own pom.xml, which contains the module name among other information. In addition, they contain the dependencies, i.e., the Java libraries they use.

Listing 13.2 Part of pom.xml Including Dependencies




Listing 13.2 shows a part of a pom.xml, which lists the dependencies of the module. Depending on the nature of the Spring Cloud features the project is using, additional entries have to be added in this part of the pom.xml usually with the groupid

The build process results in one JAR file per microservice, which contains the compiled code, the configuration, and all necessary libraries. Java can directly start such JAR files. Although the microservices can be accessed via HTTP, they do not have to be deployed on an application or web server. This part of the infrastructure is also contained in the JAR file.

As the projects are built with Maven, they can be imported into all usual Java IDEs (integrated development environment) for further development. IDEs simplify code changes tremendously.

Try and Experiment

• Download and compile the example:

Download the example provided at Install Maven; see In the subdirectory microservices-demo execute the command mvn package. This will build the complete project.

• Create a continuous integration server for the project: is an example project for a continuous delivery project. This contains in subdirectory ci-setup a setup for a continuous integration server (Jenkins) with static code analysis (Sonarqube) and Artifactory for the handling of binary artifacts. Integrate the microservices project into this infrastructure so that a new build is triggered upon each change.

The next section (13.4) will discuss Vagrant in more detail. This tool is used for the continuous integration servers. It simplifies the generation of test environments greatly.

< Prev   CONTENTS   Source   Next >