何时使用javax.ws.rs.core.Application创建RESTful Web服务? [英] When to use javax.ws.rs.core.Application to create RESTful web services?

查看:1493
本文介绍了何时使用javax.ws.rs.core.Application创建RESTful Web服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以两种方式开发了RESTful Web服务:

I have developed RESTful web services in two ways:

  1. 使用了通过Glassfish扩展javax.ws.rs.core.Application而不定义web.xml文件的类.

没有使用javax.ws.rs.core.Application,但是包括了web.xml和使用Tomcat的Jersey实现.

haven't used javax.ws.rs.core.Application but included a web.xml and a Jersey implementation, using Tomcat.

是否存在使用JAX-RS构建RESTful Web服务的首选方法?

Is there a preferred way of building RESTful web services with JAX-RS?

推荐答案

使用javax.ws.rs.core.Application类是在JAX-RS Web服务中配置资源和提供程序的首选方法,也是唯一的可移植方法, 因此,如果可能的话,这将是建议的设置方式.

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.

但这仅在对JAX-RS敏感的servlet容器或应用程序服务器中有效,对于不对JAX-RS敏感的服务器,您需要其他部署方式,并且大多数情况下,这意味着您需要JAX-RS实现的一些专有servlet类.正在使用.

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.

要获取有关此主题的更多详细信息,请参阅例如Jersey文档,部署RESTful Web服务(适用于Jersey v1.x)和应用程序部署和运行时环境(适用于Jersey v2 .x).

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).

这篇关于何时使用javax.ws.rs.core.Application创建RESTful Web服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆