Creating Simple Java Microservice

Last updated: 2025-09-14

This section shows how to create a simple REST Microservice service based on Java Jackson and Jersy API’s in no-time.

Steps:

  1. Create Maven project with the following pom.xml:

Unresolved include directive in modules/6.x.x/pages/frameworks/jk-framework/jk-framework-service/java-simple-microservice-tutorial.adoc - include::inc/simple-service/pom.xml[]

If you are using Eclipse, be sure to refresh your project (select your project→ right click→ Maven→ Update Project)

  1. Create Person class as a model class at src/main/java/com/app/model/Person.java such as the following:

Unresolved include directive in modules/6.x.x/pages/frameworks/jk-framework/jk-framework-service/java-simple-microservice-tutorial.adoc - include::inc/simple-service/src/main/java/com/app/model/Person.java[]
  1. Create ExampleService as sREST service at src/main/java/com/app/service/ExampleService.java, such as the following:

Unresolved include directive in modules/6.x.x/pages/frameworks/jk-framework/jk-framework-service/java-simple-microservice-tutorial.adoc - include::inc/simple-service/src/main/java/com/app/service/ExampleService.java[]
  1. Create App class at src/main/java/com/app/App.java for quick testing with the following contents:

Unresolved include directive in modules/6.x.x/pages/frameworks/jk-framework/jk-framework-service/java-simple-microservice-tutorial.adoc - include::inc/simple-service/src/main/java/com/app/App.java[]

Run your App class, you should see something like this in your console:

console
output
Figure 1. Navigate to http://localhost:8080/app/example/hello , you should see something like this:

The available end-points are:

Now, you can test the Microservice with your preferred API client such as Talend or PostMan.

To call the this Microservice from Java client, you can follow this - Create Simple Microservice Client

Full example source-code can be found at https://github.com/smartapi-com/j-framework-microservice