Restskeleton is a small Rest web-service written in Java and using RestEasy 3 + Spring 3 + Maven 3.
The RestEasy is used to create the web resources, Spring to inject and manages the dependencies and Gson is used to convert object into JSON.
You can use it to prototype your Rest API or in production, why not? ;)
The ResponeBody is a valid JSON object with Content-type: application/json.
(This project uses an embedded version of Jetty.)
- Java 7
- Maven 3
- Servlet-api 3.x
- RestEasy 3.0.x
- Spring 3.2.x
- Gson 2.4
$ mvn clean install
$ mvn jetty:run
To see the results of the rest services, you can access:
Product service test:
http://localhost:8080/rest/product
{
"success": "Endpoint of product works"
}
Get product by id:
http://localhost:8080/rest/product/123
{
"id": 123,
"name": "Silent Hill 2",
"description": "Game Silent Hill 2",
"keywords": [
"silent hill 2",
"game",
"playstation 2",
"xbox",
"pc"
]
}
You can change or add a new Resource inside the package:
src/main/java/com/example/restskeleton/resources/
src/test/java/com/example/restskeleton/resources/ProductResourceTest.java
If you use Eclipse to develop, you can import this application as an "Existing Maven Projects".
- Right click on Package Explorer
- Import...
- Existing Maven Projects
- Select the project folder
- Click on Finish button
I hope you enjoy :)