java Restlet 与 Spring MVC 的 Restful Web 服务

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2656819/
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-29 22:14:46  来源:igfitidea点击:

Restlet vs Spring MVC for Restful web service

javagoogle-app-enginespring-mvcrestlet

提问by zachariahyoung

I'm researching how best to create a Restful web service on Google app engine. My end goal is to have an Android application call a web service on GAE to post and get data. At this point I not sure what the best approach is.

我正在研究如何最好地在 Google 应用引擎上创建一个 Restful 网络服务。我的最终目标是让 Android 应用程序调用 GAE 上的 Web 服务来发布和获取数据。在这一点上,我不确定最好的方法是什么。

What I know at this point is Spring MVC 3 provide the ability to create web service but it does not provide a full implementation of JAX-RS. I also have read a few blog that talk about how Spring and Restlet can be integrated together. On the other side I have read that I could only use Restlet in GAE. I would also like provide a light web interface for users to view their posted data

目前我所知道的是 Spring MVC 3 提供了创建 Web 服务的能力,但它没有提供 JAX-RS 的完整实现。我还阅读了一些博客,其中讨论了如何将 Spring 和 Restlet 集成在一起。另一方面,我读到我只能在 GAE 中使用 Restlet。我还想为用户提供一个轻量级的网络界面来查看他们发布的数据

So my questions are the following. 1. Should I just use Restlet. 2. Should I just use Spring MVC to provide my Restful web service. 3. Should I use Spring and Restlet together.

所以我的问题如下。1.我应该只使用Restlet。2. 我是否应该只使用 Spring MVC 来提供我的 Restful Web 服务。3. Spring和Restlet应该一起用吗?

At this point I think I should invest my time in Restlet because that seems to be the best approach for calling web services in Android. I'm also debating if Spring MVC is just over kill.

在这一点上,我认为我应该把时间花在 Restlet 上,因为这似乎是在 Android 中调用 Web 服务的最佳方法。我也在争论 Spring MVC 是否刚刚结束。

Any thoughts would be helpful.

任何想法都会有所帮助。

回答by Diego

I recently set up RESTlet on GAE and it was an absolute breeze! There are docs outlining the procedure on the RESTlet website and I was up and running RESTlet on GAE using the Google datastore within two hours.

我最近在 GAE 上设置了 RESTlet,这绝对是轻而易举的事!RESTlet 网站上有一些文档概述了该过程,我在两小时内使用 Google 数据存储在 GAE 上启动并运行了 RESTlet。

The major downside is that performance of the Google data store for low volume apps is atrocious. Timeouts are not uncommon. (Google mandates a maximum 30 second request time and your app can easily take up half of that in coming out of hibernation if it hasn't been accessed recently)

主要的缺点是 Google 数据存储对于低容量应用程序的性能非常糟糕。超时并不少见。(Google 规定最多 30 秒的请求时间,如果您的应用最近没有被访问过,它可以轻松地在退出休眠状态时占用其中的一半时间)

Right now I am building another RESTful app and chose to go the Spring 3 MVC / Hibernate / MYSQL route. I am not new to Spring DI or MySQL, but I am new to Spring MVC and it is taking me days to work through all the issues I am encountering. I am disappointed in the quality of available documentation and I have not been able to find a reasonable and complete Spring 3 MVC RESTful CRUD tutorial anywhere. Argh.

现在我正在构建另一个 RESTful 应用程序并选择使用 Spring 3 MVC/Hibernate/MYSQL 路线。我对 Spring DI 或 MySQL 并不陌生,但我对 Spring MVC 并不陌生,我需要几天时间来解决我遇到的所有问题。我对可用文档的质量感到失望,而且我无法在任何地方找到合理且完整的 Spring 3 MVC RESTful CRUD 教程。啊。

回答by pjesi

I don't have experience with Restlet but Spring MVC 3.0 is quite powerful for building restful webservice AND webapps. So if you also plan for your service to be accessible through browsers then it is a great solution since your controllers can serve both apps and browsers.

我没有使用 Restlet 的经验,但 Spring MVC 3.0 对于构建 Restful webservice 和 webapps 非常强大。因此,如果您还计划通过浏览器访问您的服务,那么这是一个很好的解决方案,因为您的控制器可以同时为应用程序和浏览器提供服务。

Perhaps this is also possible with Restlet but I have not heard of its capabilities for building webapps.

也许 Restlet 也可以做到这一点,但我还没有听说过它构建 web 应用程序的能力。

Just beware that Spring has a high loading time. This means that you have to be careful to avoid slow responses from cold starts.

请注意 Spring 的加载时间很长。这意味着您必须小心避免冷启动时的缓慢响应。