This tutorial will show how to import a Java EE RESTEasy application using the example of a simple adder application. It allows you to quickly get started with Eclipse and RESTEasy.
- Download the adder service application source files (Project on GitHub) to a temporary folder.
Import the archive as described in the basic Java EE tutorial.
Imported Project AdderServiceResteasy
- Once you published your projects onto your application server and started the server, your adder service is accessible under http://localhost:8080/AdderServiceResteasy/api/.
- Try changing parts of the URI, i.e. …/api/add/1/3/. Also try to send different Accept-Header using a curl-like tool such as httpie, REST Console for Chrome, or RESTClient for Firefox to see how the resource responds with different representations.
- Also try the sample client that uses the RESTEasy web service.
Using a dynamic web project, add the following to your
WEB-INF/web.xml in order to let RESTEasy discover your resources:
<servlet-mapping> <servlet-name>javax.ws.rs.core.Application</servlet-name> <url-pattern>/api/*</url-pattern> </servlet-mapping>