Simple REST web service using Eclipse

 

As part of my work I had to create a REST client using Java and I ended up creating a REST web server to test my client

Before you start, you should have a minimum understanding of Web service, HTTP, Eclipse and Java (JAX-RS)

Things you need to have installed JDK, Eclipse and Tomcat (or TomEE).  I Used Eclipse Version: 2020-06 (4.16.0) and Tomcat version 9 and JDK 8

Below are the steps

1.   Create an eclipse Maven project (File->New->Maven Project or File->New->Other->Maven Project)





Click Next


2. In the next screen, leave the defaults as is and click Next


3. Type "jersey" into the Filter textbox , wait for it to populate the scrollbox beow, scroll down and select "jersey-quickstart-webapps"





 
Note: Unselect "Show the latest version..." checkbox and select a suitable version (leaving it checked will only show the latest version which failed for me when maven was downloading the dependencies)

4. Fill in project Group Id, Artifact Id and click on Finish


Eclipse will generate all the needed code and config.

5. Once eclipse is done, you can create a WAR file and deploy to Tomcat to test the sample Rest webservice and resource


 

You can test your web service using a client like SOAP UI or Postman



6. Now you can add your custom logic in the generated class or add your own implementation




Comments

Popular posts from this blog

Creating a simple SOAP web service using Eclipse

Building Apache httpd from source