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

后端 未结 1 764
梦毁少年i
梦毁少年i 2021-02-20 08:59

I have developed RESTful web services in two ways:

  1. used a class that extends javax.ws.rs.core.Application without defining a web.xml f

1条回答
  •  梦毁少年i
    2021-02-20 09:44

    Using the javax.ws.rs.core.Application class is the preferred way and also the only portable way of configuring resources and providers in a JAX-RS web service, so if possible that would be the recommended way to set it up.

    But that works well only in JAX-RS aware servlet containers or application servers, for JAX-RS non aware servers you need other ways for deployment and that most of the times means some proprietary servlet class of the JAX-RS implementation you are using.

    To get more details on the subject, see for example the Jersey documentation, Deploying a RESTful Web Service (for Jersey v1.x) and Application Deployment and Runtime Environments (for Jersey v2.x).

    0 讨论(0)
提交回复
热议问题