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?
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 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.
Spring Boot has excellent support for JAX-RS web services. You generally have two JAX-RS implementations to choose from: Jersey. Apache CXF.
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.
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:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With