java - RESTEasy 与 Apache Ant
问题描述
我们使用 Apache Ant 构建我们的应用程序,我正在尝试使用 REST 公开一些服务。我使用 RESTEasy 作为实现。我已经下载了 resteasy-jaxrs-2.3.5.final.jar 并将其添加到我当前项目的类路径中。我还在 web.xml 中创建了条目,我的 web.xml 看起来像这样:
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_3.dtd">
<web-app id="WebApp_ID" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Restful Web Application</display-name>
<!-- Auto scan REST service -->
<context-param>
<param-name>resteasy.scan</param-name>
<param-value>true</param-value>
</context-param>
<!-- this need same with resteasy servlet url-pattern -->
<context-param>
<param-name>resteasy.servlet.mapping.prefix</param-name>
<param-value>/rest</param-value>
</context-param>
<listener>
<listener-class>
org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
</listener-class>
</listener>
<servlet>
<servlet-name>resteasy-servlet</servlet-name>
<servlet-class>
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>resteasy-servlet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
</web-app>
但是当我编写端点类时,找不到像 @Path 这样的 REST 注释,因此我无法使用任何 REST 注释来注释我的类。谁能建议我需要做什么?
解决方案
@Path
来自jaxrs-api
罐子。您需要确保您的 ANT 构建在拉动resteasy-jaxrs-2.3.5.final.jar
. 如果不是,您需要使用编写/编译/构建存档所需的所有依赖项来更新您的 ANT 构建文件。
推荐阅读
- c++ - 不考虑模板构造函数
- f# - F# 中的扩展类型
- google-play-developer-api - Google Play Developer API:什么是 APK 的编辑标识符以及(如何)以编程方式找到它
- python - 使用像 LIKE 这样的原始 SQL 命令
- python - 从集合中获取第一个元组
- multiple-columns - 我需要更新两个字段;一个依赖于另一个
- python - ValueError:无法将字符串转换为浮点数:模型
- google-cloud-pubsub - 在 PubSub 订阅确认截止日期和重新发送的上下文中,未发送给订阅者的消息是什么意思?
- arrays - 使用 Laravel 中的对象遍历集合
- sql - 使用 PL/SQL 将大型 XML 结果打印到 ORA-10260:超出事件 10261 设置的 PGA 堆的限制大小 (1048576)