Inheriting included app component's rest-dispatcher-spring configurations

I have an app component which has included rest addon and some custom RestController and configurations in its rest-dispatcher-spring.xml file.

When I include this app component into a new project, how can I “inherit” the custom RestControllers and rest-dispatcher-spring configurations into the new project ?

E.g. I configured SwaggerConfig in the app component but this is not available in the new project.

I thought if I put the following line into my new web-app.properties it will include all the app components rest-dispatch-spring configurations.

cuba.restSpringContextConfig = +com/example/demo/rest-dispatcher-spring.xml

Hi,
Maybe this sample project will help you:

It does a similar thing, registering addititional beans for REST controllers context.

Hi,

Over the weekend I looked at the REST Addon source code in Github and I noticed that in the app-context.xml file in the project, there is another line in the file which is not in my typical app descriptor.

    <property name="cuba.restSpringContextConfig"
              value="+com/haulmont/addon/restapi/rest-dispatcher-spring.xml"/>

I assume that this will enable the configurations in the rest-dispatcher-spring.xml in the add-on to be “inherited” into the new project. So I included a similar line in the app component module. With this line, I find that I don’t need to copy all the customized configurations in the app component rest-dispatcher-spring.xml into the new project. I only need to add the line:

<context:component-scan base-package=“com.haulmont.addon.restapi.api”/>

in the new project’s rest-dispatcher-spring.xml to scan for new project’s controllers to be added, in addition to the app component controllers and all its customization.

1 Like