且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

JAX-RS Web服务在哪个容器中运行?

更新时间:2023-11-18 07:56:22


tomcat是否使用JAX-RS的另一个实现除了Jersey?

"Does tomcat uses another implementation of JAX-RS other than Jersey?"

我不知道你是否在询问Tomcat是否有实现或者是否能够运行泽西岛旁边的其他实施。

I don't know if you're asking if Tomcat has an implementation or if it is capable of running other implementations beside Jersey.

前者的答案是否定的。 Vanilla Tomcat不支持JAX-RS。它不是EE服务器,而只是一个Servlet容器。但 TomEE + (基于Tomcat构建)支持(使用CXF)。

The answer to the former is no. Vanilla Tomcat does not support JAX-RS out the box. It is not an EE server, but simply a Servlet container. But TomEE+ (built on Tomcat) has support (using CXF).

后者的答案是肯定的。您只需要添加实现jar并正确配置应用程序

The answer to the latter is yes. You just need to add that implementations jars and configure the app properly


如果没有捆绑的jar,我无法运行Jax-RS应用程序战争文件

"I could not run the Jax-RS application without the jars bundled into the war file"

是的,你不能。简单来说,没有实现来支持JAX-RS运行时。

Yup, you can't. For the simple fact there is no implementation to support the JAX-RS runtime.


这意味着它们不在Web容器中运行。那么它在哪个容器中运行?

"It means they do not run in a web container. then in which container does it run?"

它确实在Servlet容器中运行。 JAX-RS实际上是建立在Servlets之上的。对于Jersey,它使用 ServletContainer 。 Tomcat将向Jersey Servlet发送请求,Jersey将通过配置的提供者和资源处理请求,并将响应吐出回容器。容器将响应发送给客户端。 (请参阅下面的第一个链接)

It does run in the Servlet container. JAX-RS is actually built on top of Servlets. For Jersey, it uses the ServletContainer. Tomcat will ship off requests to the Jersey Servlet, and Jersey will process the request through configured provider and resources and spit out the response back to the container. The container will send the response to the client. (See first link below)

如果您正在寻找支持整个EE规范的Java EE应用服务器,你可以看看Glassfish(它使用Jersey作为它的实现),JBoss / Wildfly(它使用Resteasy),上面提到的TomEE +(使用CXF)

If you are looking for a Java EE application server, that supports the whole EE spec, you can look at Glassfish (it uses Jersey as it's implementation), JBoss/Wildfly (it uses Resteasy), TomEE+ mentioned above (uses CXF)

以下是一些您可能感兴趣的相关读物:

  • Confusion with JAX-RS and Jersey with JAX-RS
  • JAX-RS specification - 2.3 Publication
  • Java-ee REST server with IntelliJ and Tomcat
  • How to use Jersey as JAX-RS implementation without web.xml?