| Start | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Creating a REST-Service
or type web in
now try to run the application and call this URL http://localhost:8080/api2/users (opens new window) |
||||||||||||||
| Creating a Rest Service with JERSEY and Spring Boot Jersey is one of the many frameworks available to create Rest Services, This example will show you how to create Rest Services using Jersey and Spring Boot 1.Project SetupYou can create a new project using STS or by using the Spring Initializr (opens new window) page. While creating a project, include the following dependencies:
2.Creating a ControllerLet us create a controller for our Jersey Web Service
3.Wiring Jersey ConfigurationsLet us now configure Jersey Framework with Spring Boot:
Create a class, rather a spring component which extends
It is a good idea to annotate the configuration class with 4.DoneStart the application and fire a sample URL like (Assuming you have configured spring boot to run on port 8080):
You should see a message in your browser like: Welcome User And you are done with your Jersey Web Service with Spring Boot |
||||||||||||||
| Consuming a REST API with RestTemplate (GET) To consume a REST API with Once you've set up your project (opens new window), create a After that, create a domain class, similar to how you should do when creating a REST service (opens new window). In your client, autowire the To consume a REST API that is returning a single user, you can now use: Consuming a REST API that is returning a list or array of users, you have two options. Either consume it as an array: Or consume it using the Be aware, when using Parameters
|
Read Article
https://develop.horje.com/learn/1434/reference