Do I necessarily need a third party framework for

2019-06-20 11:06发布

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条回答
ゆ 、 Hurt°
2楼-- · 2019-06-20 11:33

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.

查看更多
一纸荒年 Trace。
3楼-- · 2019-06-20 11:46

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

查看更多
登录 后发表回答