Spring Boot Jersey Example

Spring Boot Jersey Example

Spring Boot Jersey Example:-

Today we are going to learn about configuring Spring Boot and Jersey. We can create Rest services in Spring using spring @RestController, then Why do we want to integrate Jersey in Spring Boot.Let’s try and understand this first.

You must be knowing about JAX-RS. JAX-RS is a specification for implementing REST web services in Java, currently defined by the JSR-370. Jersey is the pure reference implementation of JAX-RS. Spring is a framework itself having Rest support.Spring RestController is not a JAX-RS reference implementation, but it’s an alternative. Spring Rest is not a core implementation of JAX-RS.

Project Structure:-

Spring Boot And Jersey








Project Dependencies:-

Declare spring-boot-starter-jersey as your dependency, as we use Jersey in our project.

Configure Spring Boot Jersey:-

Create a file JerseyConfig.java and add the following piece of code. Here we are configuring /api as the base context of the web service.

Configure Spring Boot Jersey Rest Endpoints:-

In the end, the difference in choosing between them usually comes down as  Are you already or do you plan to integrate any other Spring libraries into your application? If so Spring REST is the way to go as you’ll have a much easier time integrating it, otherwise, it is really just personal preference which you’d prefer to use.

If your project has chances of getting migrated to different frameworks in near future then Jersey is the way to go.Personally, I like Jersey but the power of other related Spring projects makes spring a good choice as well.

Be the first to comment

Leave a Reply

Your email address will not be published.