Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring MVC REST is not JAX-RS compliant. Does it matter? [closed]

I've had good experience with Spring MVC REST with a couple of solid projects delivered. My question is about JAX-RS compliance. Does it matter because Spring is here to stay and I don't foresee (nor have a reason to) having to move away from Spring MVC REST to Jersy or any other JAX-RS impl any time soon. Anything that should force me to think about using JAX-RS implementation as opposed to Spring MVC REST?

like image 811
user6123723 Avatar asked Nov 15 '13 17:11

user6123723


People also ask

Is spring REST JAX-RS compliant?

Spring Framework The REST capabilities are provided by the Spring MVC module (same module that provides model-view-controller capabilities). It is not a JAX-RS implementation and can be seen as a Spring alternative to the JAX-RS standard.

Why do we need JAX-RS?

Why use JAX-RS / Jersey? Because it makes the development of RESTful services easier. JAX-RS is a standard that makes it easy to create a RESTful service that can be deployed to any Java application server: GlassFish, WebLogic, WebSphere, JBoss, etc.

Can we use JAX-RS in spring boot?

Spring Boot has excellent support for JAX-RS web services. You generally have two JAX-RS implementations to choose from: Jersey. Apache CXF.

What is difference between Jersey and spring REST?

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.


1 Answers

IMHO, if your web application returns JSON/XML only, there is no big difference. However, if some end points of your web application need to return HTML, Spring MVC is better. The reason I think so is that JAX-RS does not provide any MVC mechanism (AFAIK). Jersey (one of JAX-RS implementations) provides Viewable/Template to support MVC, but it is a Jersey-specific feature and not a part of JAX-RS specification.

Chapter 18. MVC Templates
https://jersey.java.net/documentation/latest/mvc.html

Also, this blog may give you some insights.

Jersey JAX-RS MVC Killed the Spring MVC Star
http://sleeplessinslc.blogspot.jp/2012/02/jersey-jax-rs-mvc-killed-spring-mvc.html
(The conclusion of the blog is different from its title, though.)


EDIT - here's the answer to the question asked:

Standardized annotations

As the 2nd link above says:

Jersey is a JAX-RS implementation, one could swap out Jersey for another provider like RestEasy if desired without much effort. Spring MVC on the other hand has REST web service support but the same is not a JAX-RS implementation and therefore one is tied to Spring MVC.

like image 57
Takahiko Kawasaki Avatar answered Sep 19 '22 17:09

Takahiko Kawasaki