我们使用Apache构建应用程序,我试图使用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注释对类进行注释。有人能建议我该怎么做吗?
发布于 2018-05-15 13:08:08
@Path来自jaxrs-api jar。您需要确保ANT在提取resteasy-jaxrs-2.3.5.final.jar时提取所有的依赖项。如果不是,您需要用编写/编译/构建存档所需的所有依赖项更新ANT构建文件。
https://stackoverflow.com/questions/50350795
复制相似问题