There are three ways that you can create a new Java microservice for use with Microservice Builder:

We would recommend using the Developer CLI as you will be able to create, build and test your application locally with no Maven or programming language prerequisites; only Docker is needed. Whichever route you choose, you will get a skeleton project that contains all of the artifacts needed to build a WAR file, wrap it in a Docker image, and then deploy on to Kubernetes with the Microservice Builder pipeline.

Developer CLI

The Developer CLI is a plugin to the Bluemix CLI. Note that you don’t need to have a Bluemix ID in order to use the CLI.

  1. Install the Bluemix CLI by running one of the following commands respective to your OS:
    • macOS – sh <(curl -fsSL
    • Linux - sh <(curl -fsSL
    • Windows PowerShell - iex(New-Object Net.WebClient).DownloadString('')
    • Alternatively, follow the instructions here
  2. Install the developer plugin by running bx plugin install dev -r Bluemix
  3. Create a new microservice by running the bx dev create command. Follow the prompts to create a basic Java microservice in the directory of your CLI
  4. In this directory you will find:
    • Java source code for a JAX-RS application with a healthcheck endpoint
    • A Maven pom.xml to build the application
    • A Dockerfile to build the Docker image for the application
    • A Jenkinsfile used to build the application in the Microservice Builder pipeline
    • Kubernetes configuration to define the deployment of the application
  5. Here we'll edit in the src/main/java directory to add a new JAX-RS endpoint:
public class Example {
  public Response hello() {
    return Response.ok("Hello World").build();

Build and run the code locally

The bx dev CLI can also be used to build and run the application locally

  1. Run bx dev build to perform a Maven build of the application. This build takes place inside a Docker container so that you do not need to have Java or Maven installed on your local system. You can add the --trace option if you want to see the output logs from the Maven build
  2. Execute bx dev run to build a Docker image containing the built application and run it
  3. Once WebSphere Liberty has started, you can now access the JAX-RS endpoint at http://localhost:9080/<project>/hello where <project> is the name you gave to your application project

Deploy your application with the Microservice Builder pipeline

  • Push your project to a repository in the GitHub organization that the pipeline is monitoring and it will be automatically built and deployed

Bluemix console

The Bluemix console can be used to obtain a project with the same structure as created by bx dev create but without installing anything locally. You will then need Java and Maven to build and run the microservice locally.

  1. Head to the Bluemix console and log in
  2. Choose Microservice and click Next
  3. Select a Microservice Starter; at the time of writing this article only Basic is available
  4. Fill in the required fields and then click Create
  5. Click Get the Code, then Generate Code and finally Download Code
  6. You will be given a .zip file containing your project
  7. You can now use the project as you would with the Developer CLI. After installing the Bluemix CLI and Developer Plug-in you can build and run your application using bx dev build and bx dev run respectively.

Liberty App Accelerator

The Liberty App Accelerator is another web-based mechanism for generating a project skeleton but with a focus on selecting different Java technologies for inclusion in the project.

  1. Head to the App Accelerator
  2. When asked to select a technology type, choose Microservice Builder
  3. Based on the options you selected you will either be given a .zip file with your project inside or will have a repository created on GitHub containing your project
  4. The app will be ready for development, containing a Dockerfile, a Jenkinsfile and a pom.xml. It doesn't however come with the configuration files needed to use the bx dev CLI. To run this project locally, use the mvn clean, mvn install and mvn liberty:run-server goals.

Join The Discussion

Your email address will not be published. Required fields are marked *