Using the Spring Boot CLI (or Spring Initializr) to init a Jersey JAX-RS app

To use the Spring Boot CLI to init an app using Jersey JAX-RS apis, use:

spring init --build=maven --dependencies=jersey --packaging=jar

Unzip the packaged app, import into your IDE.

To get Spring Boot to initialize Jersey and see your annotated resources, you need to add a Spring component that extends Jersey’s ResourceConfig class, and call register() for each of your Resources (seems odd that you need to explicitly register your endpoints like this, as in a War deployed to a Servlet container they would get found automatically?)

import org.glassfish.jersey.server.ResourceConfig;
import org.springframework.stereotype.Component;

public class JerseyExampleConfig extends ResourceConfig {

public JerseyExampleConfig() {


Additionally, each Resource endpoint class needs to be @Component annotated so Spring can managed them.

Your JAX-RS resources classes other than above are implemented as normal.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.