How to Deploy Microservices on Google Cloud

Today, I'll show you how you can deploy a multi module project on GAE using Maven. Because the EAR file is not allowed, we basically wrap our microservices inside a parent module (pom).

Parent Module

The parent module has its packaging tag set to pom.

All shared configuration will be placed inside the parent pom.xml via dependencyManagement or pluginManagement.


As you probably know Maven provides the notion of aggregation by declaring submodules explicitly in the parent pom.xml. In the above configuration, I've declared 3 submodules (war).

You can create the parent project with the following cmd:

mvn archetype:generate -DgroupId=com.vedrax -DartifactId=parent-project

PS: I'll soon register an archetype to generate the configuration as presented above with the required submodules.

Submodules

You can in the parent's directory run the following cmd:

mvn archetype:generate -DgroupId=com.vedrax -DartifactId=company-service
mvn archetype:generate -DgroupId=com.vedrax -DartifactId=product-service
mvn archetype:generate -DgroupId=com.vedrax -DartifactId=certification-service

Maven will generate for you 3 empty projects. It'll also modify the modules tag on the parent's pom.xml as below:


Below is a complete example of the pom.xml as declared in the company-service :



As a bonus, you will be able to run a Spring boot project with the sample code above on GAE.

Conclusion


In this tutorial, we discussed the way we generate a multi modules app in GAE.

Comments

Popular posts from this blog

Spring JPA : Using Specification with Projection

Chip input using Reactive Form