泽西岛:无法解析org.glassfish.jersey.server.mvc [英] Jersey: org.glassfish.jersey.server.mvc cannot be resolved
问题描述
我想在我的项目中使用Jersey MVC. 我以前从未使用过Jersey MVC.
I want to use Jersey MVC in my project. I've never used Jersey MVC before.
我在工作:
- Eclipse(版本:Neon.1a发行版(4.6.1))
,使用:
-
Jersey 2.25.1
Jersey 2.25.1
Apache Tomcat 7.0.76.
Apache Tomcat 7.0.76.
这是我要运行的示例:
Hello.java
MyApp.java
NewFile.jsp
我已经从此处
并在
这是我所谓的网络服务的方式:
Here's how I call my web service:
带下划线的导入行说明:
The underlined import line tells:
这就是我要解决的问题.
So this is the problem I want to solve.
因为我没有找到与这个问题相关的任何信息,所以我搜索了与泽西mvc相关的jar文件.我找到了它
Because I have not found any information related to this problem I searched for jersey mvc related jar file. I found it here.
我在 lib 文件夹中添加了 jersey-mvc-2.25.1.jar .
因此找到了包(和Viewable类).
So the package (and Viewable class) was found.
但是当我在服务器上运行时,会得到以下堆栈跟踪:
But when I run on server I get the following stack trace:
谢谢.
推荐答案
这是我解决问题的方法:
Here's how I solved the problem:
First of all, jersey-mvc-2.25.1.jar is not enough to use MVC Jersey.
我下载了文件 jersey-mvc-jsp-2.25.jar .
我将两个罐子都放在了 lib
I put both jars in lib
现在这是我工作的基本示例:
Now here's my working basic example:
我的项目的结构是:
源代码为:
MyApp.java
Hello.java
NewFile.jsp
要查看结果,我启动了Tomcat服务器,然后:
To see the result I started the Tomcat server, then:
成功了!
与Eclipse中的classpath/buildpath设置有关:
Related to classpath/buildpath setting in Eclipse:
我没有在类路径或构建路径中添加Jars(jersey-mvc-2.5.1.jar和jersey-mvc-2.5.1.jar).无论如何,它仍然有效.
I didn't Add Jars (jersey-mvc-2.5.1.jar and jersey-mvc-2.5.1.jar) in classpath or buildpath. It worked anyway.
真正有助于理解所有这些的是:
What really helped to understand all this is:
这篇关于泽西岛:无法解析org.glassfish.jersey.server.mvc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!