Jersey 只是一个用 Java 开发 RESTful Web 服务的框架吗?
我的理解是,Java EE 6 包含 JSR 311 规范文档中定义的 java.ws.rs (JAX-RS) 类。但我不知道如果 Java EE 6 中已经内置了基类,为什么还要使用 Jersey 或 Apache CXF。难道不能单独使用这些类创建 RESTful Web 服务吗? Jersey、Apache CXF 等只是使基于 REST 的 Web 服务的开发变得更容易的框架吗?
The way I understand it is Java EE 6 includes the classes for java.ws.rs (JAX-RS) which are defined in the JSR 311 spec document. But I don't know why you would use Jersey or Apache CXF if the base classes are already built into Java EE 6. Can you not create a RESTful web service with those classes alone? Are Jersey, Apache CXF, etc just frameworks to make development of REST-based web services easier?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Java EE只定义了标准,这些类是标准的API,但它们背后没有实现。 Jersey 和 CXF 是该标准的竞争实现。
但是,如果您有一个声称支持 Java EE 6 的服务器,那么它必须包含标准中每个 API 的实现。例如,Glassfish 包含 Jersey,因此您不必显式添加它。
Java EE only defines standards, those classes are the standard API, but there is no implementation behind them. Jersey and CXF are competing implementations of the standard.
However, if you have a server that claims to support Java EE 6, it will have to contain an implementation for every API that's in the standard. For example, Glassfish includes Jersey, so you don't have to add it explicitly.
JAX-RS 只是一个规范。为了使用 JAX-RS,您需要该规范的实现。
Jersey 是一个 JAX-RS 实现。具体来说,它是参考实现。
JAX-RS is just a specification. In order to use JAX-RS, you need an implementation of the spec.
Jersey is a JAX-RS implementation. Specifically, it is the reference implementation.