What is the difference between Spring REST service, Jersey REST service and Spring+Jersey solutions?

后端 未结 2 1149
天命终不由人
天命终不由人 2020-12-24 01:24

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 b

2条回答
  •  攒了一身酷
    2020-12-24 01:29

    One major difference is in the area of unit testing support.

    Jersey Test Framework does not lend itself for mocking server side code - For example, if your REST Resource depended on a Service, you would like to mock the service when testing resource methods. However, Jersey Tests run a separate container and unit tests sort of make calls to the running instance of your REST resource - at this point of time, I have not found any documentation or way for mocking server side code.

    On the contrary, Spring MVC tests do not require any containers - and are more well integrated with its controllers. Dependency Injection can be used to inject mock services / DAOs to have better unit tests.

    I also find that documentation on Spring projects are more mature when compared to Jersey.

提交回复
热议问题