Fast setup of a Java microservice project with MicroProfileStarter

In this blog post I want to show the easy setup of an own MicroProfile/OpenLiberty project with MicroProfileStarter . From my perspective that is  very useful for new Java developers, who want to build microservices. The prerequisite is, you have installed maven and Java on your local machine.

You can use for more information the MicroProfileStarter it self and the OpenLiberty getting started documentation.

That’s fits perfect to the topic Cloud-Native. Maybe you already know, we (Niklas, Harald and I) working on the open sourced Cloud Native Starter project. That project contains sample code that demonstrates, how to get started with Cloud-Native applications and microservices based architectures. Here we use also MicroProfile/OpenLiberty.

We created a new 60 -90 min hands-on workshop with the focus on Java microservice development with MicroProfile/OpenLiberty and the deployment to Kubernetes on IBM Cloud. This workshop is perfect to get a basic understanding of the Cloud-Native and Java development topics and the combination with MicroProfileStarter is awesome for newer Java Developers.

Let’s start with the usage of  the MicroProfileStarter. The MicroProfileStarter creates two microservices called service-a and service-b, which do implement the selected functionalities for MicroProfile. It took me less than 10 min to get the microservices up and running.

Here are the steps:

create-microprofile-microservices-project (1).gif

  • Step 2: Now unzip the downloaded file and open the folder with an editor. Here you find two microservices projects. Just take a brief look in readme’s and the pom file .

mp-brows-projects

  • Step 3: Then open two terminal sessions. One in each project directories of the microservices and follow the steps written in the readme’s.In the last output of the gif, we see the different URLs, where we also can check our different used functionalities of MicroProfile .
$ mvn install liberty:run-server
$ mvn clean package
$ java -jar target/sample.jar

mp-start-microservices.gif

Btw. I used the command:

 $ mvn install liberty:run-server 
  • Step 4: Verify the implementation of microservices

Just visit http://localhost:8181/index.html and test the functionalities, as described in the readme.

mp-running-services

With these steps we created two microservices based on MicroProfile/OpenLiberty very easily on our local machine, that is awesome. By the way, there is also a new visual studio code integration for the MicroProfileStarter available.

But microservices are running usually on Kubernetes. How to setup that? Just take a look in our Cloud Native Starter project and in the hands-on workshop. Here we show how build and deploy the service to Kubernetes. We build and test the container locally, with docker and deploy the microservice container to Kubernetes. In our hands-on workshop we define a Dockerfile for the microservice and we specify the deployment and service for Kubernetes. Check it out 😉

I hope this was useful for you and let’s see what’s next?

Greetings,

Thomas

PS: You can try out Cloud Foundry Apps or Kubernetes on IBM Cloud. By the way, you can use the IBM Cloud for free, if you simply create an IBM Lite account. Here you only need an e-mail address.

#ibmdeveloper, #microprofile, #openliberty, #cloudnativestarter, #cns, #kubernetes, #docker

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Blog at WordPress.com.

Up ↑

%d bloggers like this: