Springboot jersey with multiple source paths (servlets)

534 views Asked by At

I am starting to use Springboot in my application. My web.xml looks like this

    <servlet>
        <servlet-name>Internal Tools</servlet-name>
        <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
        <init-param>
            <param-name>jersey.config.server.provider.packages</param-name>
            <param-value>in.playment.internal.api;in.playment.auditor.api</param-value>
        </init-param>
        <init-param>
            <param-name>jersey.config.server.provider.classnames</param-name>
            <param-value>org.glassfish.jersey.filter.LoggingFilter;org.glassfish.jersey.media.multipart.MultiPartFeature;in.playment.gateway.RequestFilter;in.playment.gateway.ResponseFilter;in.playment.gateway.DebugExceptionMapper;in.playment.gateway.security.Binder</param-value>
        </init-param>

        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>Internal Tools</servlet-name>
        <url-pattern>/v0/internal/*</url-pattern>
    </servlet-mapping>

    <servlet>
        <servlet-name>External Apis</servlet-name>
        <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
        <init-param>
            <param-name>jersey.config.server.provider.packages</param-name>
            <param-value>in.playment.rutherford.api;in.playment.payment.api;in.playment.payment.resource</param-value>
        </init-param>
        <init-param>
            <param-name>jersey.config.server.provider.classnames</param-name>
            <param-value>org.glassfish.jersey.filter.LoggingFilter;org.glassfish.jersey.media.multipart.MultiPartFeature;in.playment.gateway.RequestFilter;in.playment.gateway.ResponseFilter;in.playment.gateway.DebugExceptionMapper;in.playment.gateway.security.Binder;in.playment.payment.exception.PaymentExceptionMapper</param-value>
        </init-param>

        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>External Apis</servlet-name>
        <url-pattern>/api/*</url-pattern>
    </servlet-mapping>

I want to use two different base paths for urls. I have different packages and different exception mappers. How can I achieve this in Springboot embedded tomcat. So far, I am able to achieve only one of these. If I try to do two registries, it throws me Exception saying org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'org.glassfish.jersey.server.ResourceConfig' available: expected single matching bean but found 2: jerseyConfig,getResourceConfig

0

There are 0 answers