Home | License | FAQ | Contact | Smart-API

Last updated: 2022-10-19

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


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

<project xmlns="http://maven.apache.org/POM/4.0.0"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">

					<!-- http://maven.apache.org/plugins/maven-compiler-plugin/ -->

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:

package com.app.model;

public class Person {

	private String name;

	private int age;

	public String getName() {
		return name;

	public void setName(String name) {
		this.name = name;

	public int getAge() {
		return age;

	public void setAge(int age) {
		this.age = age;

  1. Create ExampleService as sREST service at src/main/java/com/app/service/ExampleService.java, such as the following:

package com.app.service;

import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import com.app.model.Person;

public class ExampleService {

	public String sayHello() {
		return "Hello from uncle Jalal";

	public String sayHelloWithPathParam(@PathParam(value = "name") String name) {
		return "Hello, " + name;

	public String sayHelloWithBody(Person p) {
		return "Hello, " + p.getName() + ", your age is: " + p.getAge();
  1. Create App class at src/main/java/com/app/App.java for quick testing with the following contents:

package com.app;

import javax.ws.rs.ApplicationPath;

import com.jk.web.embedded.JKWebApplication;
import com.jk.services.server.JKServiceConfig;

public class App extends JKServiceConfig{

	 * @param args
	public static void main(String[] args) {


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

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/jk-framework-microservice

Home | License | FAQ | Contact | Smart-API