JAX-RS EJB 容器

JAX-RS EJB container

我有一个 .jar 应用程序(使用 ejbs)部署为 .ear 存档的一部分。 在这个 .jar 应用程序中,我用 @Path@Stateless 注释了 类。

我的问题是:我的 JAX-RS 资源将部署在 EJB 容器内还是 WEB (Servlet) 容器内?我是否需要定义 web.xml 并将 servlet 定义放入其中?

Are my JAX-RS resources going to be deployed inside an EJB container or inside WEB (Servlet) container?

它将部署到您的 EE 服务器的 servlet 容器中。

Do I need to define web.xml and to put servlet definition inside of it?

不一定。您可以简单地通过使用 @ApplicationPath1.

注释的空 Application subclass 来配置 JAX-RS 应用程序
@ApplicationPath("/api")
public class RestApplication extends Application {}

如果你想使用 web.xml,你可以代替这个 class。如果您确实想要,只需寻找一个教程来告诉您如何去做。但是这个 class 是最基本的配置所需要的。


脚注