There are several ways to deploy the JAX-RS applications. Some of them are illustrated as follows:
Using the abstract Application class:
In this type, we provide all the root-resource classes to the
Application
class. So, when the server is started, we need to load the Application subclass that has injected the root-resource class. Basically, when we need to set some configuration before loading the root-resource class, we can use the Application Model. Let's look at the following example:public class MainApplication extends Application { @Override public Set<Class<?>> getClasses() { Set<Class<?>> s = new HashSet<Class<?>>(); s.add(HelloWorld.class); ….. return s; } }
In
web.xml
, the path of the Application subclass needs to be defined, as shown in the following code:…. <servlet> <servlet-name>Jersey Web Application</servlet-name> <servlet...