【发布时间】:2015-07-24 00:16:24
【问题描述】:
我是 Jersey/JAX-RS/RESTful Web Services/等的新手。我在使用名为jersey-quickstart-webapp 的泽西原型时遇到了困难。我正在尝试将它与 Eclipse、Maven 和 Tomcat v7 或 v8 一起使用(我都尝试过)。
首先我遇到了一个 JSP 错误:The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path.
我用this SO question regarding the error 解决了这个错误。显然 Maven 并没有将我的项目视为动态 Web 应用程序。
然后我收到关于:Build path specifies execution environment JavaSE-1.7. There are no JREs installed in the workspace that are strictly compatible with this environment 的警告。我用another SO question on the matter 解决了第二个问题。我最初使用的是 JavaSE-1.8。
最后,我遇到了最后一个错误:Classpath entry org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER will not be exported or published. Runtime ClassNotFoundExceptions may result.Again,我检查了 SO 和 excluded the associated raw classpath entry from the set of potential publish/export dependencies。
但是,我的项目仍然收到 404,我不知道为什么。我正在为这个项目使用 pom.xml 文件。 tutorial I'm following 告诉我这里要使用的正确 URL 是 http://localhost:8080/messenger/。
【问题讨论】:
-
你在使用
http://localhost:port/your-project/webapi/myresource吗? -
localhost:8080/messenger 尝试通过右键单击从项目文件夹本身运行它 -> 运行方式 -> 在服务器上运行 (Tomcat 7)。它说 /messenger/ 是缺少的资源。我还尝试在 localhost:8080/messenger/WEB-INF/classes/org/myName/mySite/… 的 MyResource.java 上做同样的事情,并在缺少的资源下返回一个空白。
-
如果你的项目名为
messenger,你试过http://localhost:port/messenger/webapi/myresource -
我尝试了
http://localhost:8080/messenger/webapi/myresource/并得到了相同的 404 结果(也是http://localhost:port/messenger/webapi/myresource逐字)。为我的菜鸟道歉,除了 Java 和 Eclipse 之外,我对所提到的所有内容都是新手。 -
this 你是如何创建项目的?
标签: java eclipse maven tomcat jersey