This example application demonstrates how to create a REST API using:
- Spring Boot: Framework for creating standalone Java applications.
- Jersey: JAX-RS reference implementation for creating RESTful web services in Java.
- Jackson: JSON parser for Java.
To build and run this application, follow these steps:
- Open a command line window or terminal.
- Navigate to the root directory of the project, where the
pom.xml
resides. - Compile the project:
mvn clean compile
. - Package the application:
mvn package
. - Change into the
target
directory:cd target
- You should see a file with the following or a similar name:
jersey-springboot-1.0.jar
. - Execute the JAR:
java -jar jersey-springboot-1.0.jar
. - The application should be available at
http://localhost:8080/api
.
See the curl scripts below with the REST API supported operations:
curl -X GET \
'http://localhost:8080/api/greetings' \
-H 'Accept: text/plain'
curl -X GET \
'http://localhost:8080/api/current-date' \
-H 'Accept: application/json'
Alternatively to curl, you can use Postman to target the REST API. The Postman collection files are available in the src/main/postman
directory.