是的,这是可能的.您需要添加RESTeasy实现jar/dependencies.
对于Maven(resteasy.version == 3.0.9.Final)
<!-- Basic support -->
<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-jaxrs</artifactId>
    <version>${resteasy.version}</version>
</dependency>
<!-- Servlet pluggability support -->
<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-servlet-initializer</artifactId>
    <version>${resteasy.version}</version>
</dependency>
<!-- JSON/POJO support -->
<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-jackson2-provider</artifactId>
    <version>${resteasy.version}</version>
</dependency>
<!-- REST Client support -->
<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-client</artifactId>
    <version>${resteasy.version}</version>
</dependency>
您可以在下面看到Maven依赖项所引入的所有jar和传递jar(如果您不使用Maven).

您可以在这里下载所有罐子附带的分发版.同时保持文档方便.我没有包含发行版附带的所有依赖项.其他功能需要一些依赖项.如果你愿意,你可以添加所有的罐子(来自分销),但我只是向你展示它所需要的基础知识.
你还应该注意版本.3.x和2.x系列使用不同的API,因此您可能需要确切地确定您需要哪一个.我提供的链接包含所有版本的发行版和文档.为了这个答案,我只使用了3.0.9.Final.
另一件事,分发带来了一堆可能派上用场的例子.虽然所有例子都需要Maven.
使用上面的jar/dependencies,你可以简单地启动和运行一个简单的应用程序
@ApplicationPath("/rest")
public class WebConfig extends Application {
}
@Path("/simple")
public class SimpleResource {
    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public String getTest() {
        return "Hello REST World!";
    }
}
不需要额外的(web.xml)配置.对于Application带有@ApplicationPath注释的空类,所有具有的类@Path都将被注册为资源类.这可以通过resteasy-servlet-initializerservlet可插拔机制来实现.
在图像中,javaee-web-api罐子不应该在那里.我必须创建一个新的maven web项目,其中包括当我尝试创建图像时.
| 归档时间: | 
 | 
| 查看次数: | 8469 次 | 
| 最近记录: |