java 在 Eclipse 上安装和使用 jersey

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6001050/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 13:55:46  来源:igfitidea点击:

install and use jersey on Eclipse

javaspringjaxbjerseyjax-rs

提问by Spring

In my Web service I use eclipse, java 1.5, spring. now I want to use jersey for REST and downloaded the jersey as a bundle jar from this address:

在我的 Web 服务中,我使用 eclipse、java 1.5、spring。现在我想使用 jersey for REST 并从这个地址下载 jersey 作为 bundle jar:

http://jersey.java.net/nonav/documentation/latest/chapter_deps.html

http://jersey.java.net/nonav/documentation/latest/chapter_deps.html

How can I add this jar to my project and start using the JAX-rs annotations, I added to buildpath but seems like does not work.

如何将此 jar 添加到我的项目并开始使用 JAX-rs 注释,我添加到 buildpath 但似乎不起作用。

Also is it necessary or a good idea to create JAXB annotated classes of my resource classes and using them with JERSEY?

创建我的资源类的 JAXB 注释类并将它们与 JERSEY 一起使用是否有必要或一个好主意?

采纳答案by Tarlog

Make sure you have jsr-311 jar on your classpath. For example you can download it from here.

确保您的类路径上有 jsr-311 jar。例如,您可以从这里下载。

Jersey supports JAXB out-of-the-box. It doesn't mean you have to use JAXB. If you need to serialize data to/from xml, using JAXB with Jersey is the most convenient.

Jersey 支持开箱即用的 JAXB。这并不意味着您必须使用 JAXB。如果您需要将数据序列化到 xml 或从 xml 序列化数据,则将 JAXB 与 Jersey 一起使用是最方便的。