When to use javax.ws.rs.core.Application to create RESTful web services?

I developed RESTful web services in two ways:

  • used a class that extends javax.ws.rs.core.Application without defining a web.xml file using Glassfish.

  • did not use javax.ws.rs.core.Application , but included the implementation of web.xml and jersey using Tomcat.

Is there a preferred way to create RESTful web services using JAX-RS?

+5
source share
1 answer

Using the javax.ws.rs.core.Application class is the preferred method, as well as the only portable way to configure resources and providers in the JAX-RS web service, so if possible, this would be the recommended way to configure it.

But this only works well in JAX-RS servlet containers, or on application servers, for unsecured JAX-RS servers you need other deployment methods, and that most of the time means some proprietary JAX-RS servlet class that you use.

For more information on this, see, for example, the Jersey documentation, Deploying the RESTful Web Service (for Jersey v1.x) and Deploying Applications and the Runtime (for Jersey v2.x).

+6
source

Source: https://habr.com/ru/post/1200804/


All Articles