vendredi 27 février 2015

How to replicate a maven multi module, web fragment application structure in Spring boot

I am trying to replicate a Maven multi-module like application which uses web fragments in Spring boot but have been failing miserable.


Basically what I am trying to replicate in Spring Boot, which I can easily do with my regular web.xml and web-fragment.xml is to have a Spring MVC as a maven module (let's call it ModuleA) with it's DispatcherServlet mapped to /Module. This mapping and the configuration that provides the DispatcherServlet its spring config file is located in a web-fragment.xml file.


Then I have another module (let's call it ModuleB) which has the web-inf/web.xml file, has ModuleA as its dependency and it is the module that is deployed.


This set up allows for the possibility to easily embed Spring MVC as a "library" that exposes its functionality via a specific path. The the example above its /Module.


Now in Spring Boot, I have seen that by default "/" is mapped to the DispatcherServlet which makes use of a spring application context consisting of the various beans Spring-boot thinks you need plus all the classes annotated with (@Component, @Service etc). Good.


The question then is, how do I configure my Spring MVC app in another module to be exposed via it's own unique path and have access to its own Spring application context?


I have tried using ServletRegistrationBean but what that does is to replace the default "/" to whatever mapping I provide. Which is not what I want. I want the default "/" to still map to the default DispatcherServlet while I specify another path that gets mapped to another DispatcherServlet in the maven module.


Is this even possible with Spring Boot?


Aucun commentaire:

Enregistrer un commentaire