This is a simple example on how to create and consume a REST service in a Java Spring environment. Import this as a Maven project, run in a Servlet Container like Tomcat(TM) or an Application Server of your choice.
When opening the starting page: http://localhost:9090/spring-rest-example/
...you will be presented with a response from a dummy rest service. To run the other services go to the TestSpringRestExample.java right-click with mouse button and run it as a java application. Just be sure that the application is already running in your Tomcat before doing this last step.
For more information look at the following page: http://www.journaldev.com/2552/spring-restful-web-service-example-with-json-jackson-and-client-program
This example was taken from this previous link, and all the credits shloud go to Pankaj Kumar and www.journaldev.com (TM).
MS