Spring Rest服务,Jersey Rest服务和Spring + Jersey解决方案之间有什么区别? [英] What is the difference among Spring Rest service and Jersey Rest Service and Spring+Jersey solutions?

查看:140
本文介绍了Spring Rest服务,Jersey Rest服务和Spring + Jersey解决方案之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想构建一个宁静的服务/API.我使用了一些类似play的框架来构建它,但是我想尝试其他更有效的方法.我听说Jersey是用于构建其余API的通用库,而Spring也是一个很好的框架.但是我也看到了Spring + Jersey之类的解决方案.因此,对于其余的API解决方案,我有些困惑.

谁能告诉我这些之间有什么区别? Jersey REST,Spring Rest和Spring + Jersey Rest?

我的目标是建立几个其他的API,以json作为输入/输出.我将jar文件作为后端处理逻辑来处理输入的json/object并返回json/object.

非常感谢.

解决方案

Jersey是Sun提供的JAX-RS API示例实现,而Spring REST当然是Spring相同API/JSR的实现.主要区别在于Spring REST可以轻松集成到其他Spring API(如果您愿意的话),例如 Spring Data休息.

它们之间有一些值得注意的区别-您可以相互嵌入" Jersey 资源(在Spring中称为 Controllers ),以启用一个单独的类,负责某个路径的子路径,尽管在Spring中目前似乎不可用(您必须定义完整路径).另外,在我看来,Jersey可以提供更好的开箱即用"错误响应(例如,为什么它不能使用Jackson将JSON负载映射到Java bean),而Spring更具可配置性,但更简单,无需进行其他工作.

最后,选择它们之间的差异通常归结为-您是否已经打算将其他Spring库集成到您的应用程序中?如果是这样的话,Spring REST是必经之路,因为您将可以更轻松地集成它,否则,实际上只是您更喜欢使用的个人喜好.我个人喜欢Jersey,但是喜欢其他相关Spring项目的力量(例如 Spring HATEOAS ,我非常喜欢推荐)使Spring成为更好的选择.我认为您的情况不会有真正的决定性因素.

由于您的黄金"目标是带有JSON输入/输出的简单API,因此建议您遵循 Spring REST指南.

I want to build a restful service/API. I used some framework like play to build it but I want to try other more efficient ways. I heard that Jersey is a common library for building the rest API, and Spring is also a good framework. But I also saw some solutions like Spring+Jersey. Thus, I am a little confused about those rest API solutions.

Can anyone tell me what is the difference among those ? Jersey REST, Spring Rest and Spring+Jersey Rest ?

My goal is building a couple of rest API that take json as input/output. I have jar file as the backend process logic to process the input json/object and return json/object.

thanks very much.

解决方案

Jersey is the JAX-RS API example implementation provided by Sun, while Spring REST is of course Spring's implementation of the same API/JSRs. The major difference is that Spring REST easily integrates into other Spring APIs (if you wish) such as Spring Data Rest.

There are a few noteworthy differences between them - you can "embed" Jersey Resources (known in Spring as Controllers) within each other, to enable a separate class that is responsible for the sub-path of a certain path, while this doesn't appear to be available in Spring right now (you have to define the full path). Also, in my opinion Jersey gives better "out of the box" error responses (such as why it can not map a JSON payload to a Java bean using Jackson) while Spring is a bit more configurable but plainer without some additional work.

In the end the difference in choosing between them usually comes down to - are you already or do you plan to integrate any other Spring libraries into your application? If so Spring REST is the way to go as you'll have a much easier time integrating it, otherwise it is really just personal preference which you'd prefer to use. Personally I like Jersey but the power of other related Spring projects (such as Spring HATEOAS which I highly recommend) makes Spring the better choice. I don't think there will be a real determining factor in your case.

As your "gold" target is a simple API with JSON input/output, I'd recommend you follow the Spring REST guide.

这篇关于Spring Rest服务,Jersey Rest服务和Spring + Jersey解决方案之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆