当然,JAX-RS 应该无需任何额外的框架即可工作,就像 JAX-WS 一样。
但在 JAX-WS 中,我只是在 POJO 上添加一些注释,用一行代码创建一个自托管服务,仅此而已。
我找不到任何教程或资源来展示如何使用 JAX-RS 执行相同的操作。几乎每个教程都使用 Jersey(或 Easyrest 等)并且至少使用 Maven。是否没有一种简单的方法来设置基于 Rest 的服务,就像使用 JAX-WS 一样?
谢谢
编辑:嗯,我认为如果没有这些框架,@Path 等注释就无法使用?我的日食无法引用/找到它们:(
Of course JAX-RS should work without any additional framework like JAX-WS also does.
But in JAX-WS, I just put some annotations on a POJO, create a self hosted service with one single line of code and that's it.
I can't find any tutorials or resources that show how to do the same with JAX-RS. Nearly every tutorial uses Jersey (or Easyrest etc.) and at least Maven. Isn't there an easy way to set up a Rest based service like it can be done with JAX-WS?
Thank you
edit: Hm, I think annotations like @Path etc. aren't available without these frameworks? My eclipse cannot reference/find them :(
发布评论
评论(2)
JAX-RS 是一个 API。 Jersey 和 RESTEasy 是它的实现。 Jersey 是 JAX-RS 的“参考”实现,因此经常出现在教程中(毕竟,需要一些 API 实现才能使用它)。
http://en.wikipedia.org/wiki/Java_API_for_RESTful_Web_Services
JAX-RS is an API. Jersey and RESTEasy are its implementations. Jersey, is the 'reference' implementation of JAX-RS, and therefore shows up frequently in tutorials (after all, one needs some implementation of the API to use it).
http://en.wikipedia.org/wiki/Java_API_for_RESTful_Web_Services
可以轻松访问宁静的网络服务。您甚至可以使用:
URL url = new URL(docUrl);
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
您可以使用该连接,就像在其他地方使用它一样。
Restful webservices can be easily accessed. You can even use:
URL url = new URL(docUrl);
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
you can use the connection just like using it anywhere else.