简体   繁体   English

春季mvc和泽西岛之间的区别

[英]Difference between spring mvc and Jersey

Is there any trade off between using Spring mvc and Jersey Rest servlet container ? 使用Spring mvc和Jersey Rest servlet容器之间是否有任何折衷? Jersey follows Jax RS standard. 泽西遵循Jax RS标准。 When I learn Spring mvc, more or less looks the same. 当我学习Spring mvc时,或多或少看起来一样。 In some applications I found people use jersey spring servlet. 在某些应用中,我发现人们使用的是针织弹簧servlet。 If spring (dispatcher servlet with handler mapping) can do all the work, then what is the need of Jersey here ? 如果spring(带有处理程序映射的调度程序servlet)可以完成所有工作,那么Jersey需要什么呢? Thanks in advance. 提前致谢。

Spring MVC is a full Web frontend framework including support for HTML and other templating, plus other features, in addition to the JSON/XML REST features provided by Jersey. Spring MVC是一个完整的Web前端框架,除了Jersey提供的JSON / XML REST功能外,还支持HTML和其他模板以及其他功能。

Spring MVC was around first and has its own way of doing things. Spring MVC是第一个拥有自己的做事方式。 JAX-RS was defined as a standard for annotation-based REST handlers, and Jersey is an implementation of that standard. JAX-RS被定义为基于注释的REST处理程序的标准,而Jersey是该标准的实现。 (It's very similar to @Autowired and CDI.) (它与@Autowired和CDI非常相似。)

I personally prefer Spring MVC because I build on a Spring stack and can reuse code between my JSON and HTML handlers, but components intended to be deployed as one part of a customer's own system might be more flexible if using JAX-RS. 我个人更喜欢Spring MVC,因为我构建了一个Spring堆栈并且可以在我的JSON和HTML处理程序之间重用代码,但是如果使用JAX-RS,那些打算作为客户自己系统的一部分进行部署的组件可能会更灵活。

Personally I think it's just a matter of preference and what perspective you are looking at it from. 就个人而言,我认为这只是一个偏好问题以及你从中看到它的观点。 I would go on to say that when making this consideration, when building different tiers, you can say that there is an extra "REST layer", on top of the other business, persistence, etc. layers. 我会继续说,在进行这种考虑时,在构建不同的层时,可以说在其他业务,持久性等层之上还有一个额外的“REST层”。 Just like persistence implementations can be swapped out, so can REST implementations. 就像可以交换持久性实现一样,REST实现也是如此。

That being said, though the endpoint/controller/resource classes look similar in implementation, other features (of the REST layer) are implemented completely different. 话虽如此,虽然端点/控制器/资源类在实现中看起来类似,但(REST层的)其他功能实现完全不同。 Looking at it from a Spring perspective, I think those comfortable with Spring would choose to keep MVC as the REST implementation, for it's familiarity 从Spring的角度来看,我认为那些对Spring感到满意的人会选择将MVC作为REST实现,因为它的熟悉程度

Looking at it from a Jersey perspective, this is where I think most of the integration decision comes in; 从泽西岛的角度来看,这是我认为大部分整合决策的来源; choosing how to implement the layers below the REST layer. 选择如何在REST层下面实现层。 For that Spring would be a viable choice, as it has a rich eco system. 对于那个春天来说,它是一个可行的选择,因为它拥有丰富的生态系统。 But being a Jersey user, the Jersey framework (for a REST implementation) seems a lot more intuitive, but that is completely bias. 但作为Jersey用户,Jersey框架(用于REST实现)似乎更直观,但这完全是偏见。 To use Spring and Jersey together, you can have a look at Combining Spring project and Jersey 要一起使用Spring和Jersey,你可以看看Combining Spring项目和Jersey

As far as Jersey being a JAX-RS implementation, I don't see it being a deciding factor in choosing the REST implementation, when looking at it from a Spring perspective. 至于Jersey是一个JAX-RS实现,从Spring的角度来看,我不认为它是选择REST实现的决定性因素。 I really don't see it being much of a factor at all. 我真的不认为这是一个很重要的因素。 In a Java EE environment, sure you can swap out implementations with little hassle, but when Spring integration is involved, it's not that easy, as there are integration modules and configurations involved in integrating each different JAX-RS implementations with Spring. 在Java EE环境中,确保您可以轻松地交换实现,但是当涉及Spring集成时,它并不那么容易,因为集成模块和配置涉及将每个不同的JAX-RS实现与Spring集成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Spring 和 Spring MVC 框架有什么区别 - what is the difference between Spring and Spring MVC framework spring mvc:DeferredResult 和 ListenableFuture 的区别? - spring mvc: the difference between DeferredResult and ListenableFuture? root和Web应用程序之间的区别 - Difference between root and web applicationContext spring mvc Spring MVC中重定向和视图渲染的区别 - Difference between redirect and view rendering in Spring MVC Spring MVC中HandlerInterceptor和HandlerInceptorAdaptor有什么区别? - What is difference between HandlerInterceptor and HandlerInceptorAdaptor in Spring MVC? Spring MVC中拦截器和过滤器的区别 - Difference between Interceptor and Filter in Spring MVC spring mvc中的pathpattern和antpathmatcher有什么区别? - what is the difference between pathpattern and antpathmatcher in spring mvc? spring-boot-starter-web和spring-boot-starter-web-services以及spring-boot-starter-jersey之间的区别 - Difference between spring-boot-starter-web and spring-boot-starter-web-services and spring-boot-starter-jersey Spring MVC:请解释@RequestParam和@ModelAttribute之间的区别 - Spring MVC: please explain difference between @RequestParam and @ModelAttribute Spring MVC非阻塞与阻塞之间的性能差异 - Performance difference between Spring MVC non-blocking and blocking
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM