REST using JAX RS or Spring MVC

15,188

Solution 1

Depends if you want to learn something new or go with what you already know.

If you already have experience with Spring MVC and want to get the work done quickly, then I'd suggest staying with Spring MVC. There are some neat enhancements to the REST features in Spring 3.1, including the ability to generate "end point documentation".

If, on the other hand, you are looking to expand your CV and/or enjoy learning new technologies, then give JAX RS a go. I haven't used it but it is a dedicated WS framework that would likely have any feature you'd require.

Of course, if you have experience with JAX RS but not Spring MVC, then the opposite applies :-)

Solution 2

If you are developing an EE 5 project then I would recommend using JAX-RS with Spring. The RI for JAX-RS, Jersey, has a Spring JAX-RS dispatcher servlet. This makes it much easier to manage dependency injection with JAX-RS and gives you all of the Spring MVC features like form binding and validation, but you are also able to use the Java standard approach for REST - and in my opinion, a better and easier to manage approach than Spring REST.

If it is an EE 6 app, then you may want to think about ditching Spring as JAX-RS is part of the EE 6 specs and you can use EE CDI within your JAX-RS classes.

Solution 3

Notice that Jersey has a bug that affects its integration with Spring:

https://java.net/jira/browse/JERSEY-2301

In summary if you need Spring AOP in your JAX-RS resources it will not work. Dependency injection works well.

Share:
15,188

Related videos on Youtube

java_pill
Author by

java_pill

Updated on June 04, 2022

Comments

  • java_pill
    java_pill almost 2 years

    I'm trying to build a REST web service (server side) that will allow a partner system to connect/POST order information in JSON format. Should I use JAX RS (for example from JBOSS RESTEasy) or Spring MVC to build such a service? They both seem capable enough to accomplish the same thing as far as building a REST service is concerned.

    Thank you!