Skip to content
Advertisement

Does Spring Boot support multimodule maven projects?

I’m just curious about the level of support Spring Boot has for multimodule maven projects. There’s so much work that has to be done when creating a good layered set of projects (especially getting the various JPA/JDO enhancers set up). All of the samples I’ve seen put everything into one project, which is fine for simple demos.

Can Spring Boot create a nice multimodule Maven project, complete with parent pom where all dependency versions are managed, plugins are configured, and other relevant best practices, and then set up child projects for the following modules (from the bottom of the dependency chain up):

  • commons (common stuff everything depends on, utils, etc)
  • domain (persistent domain objects — JPA, JDO, etc)
  • service (service layer)
  • web (web & rest layer)

This would be really helpful. It takes HOURS to set this up initially, and lots of time to maintain it properly.

Advertisement

Answer

Spring-Boot (or spring in general) has nothing to do with the structure of the project in terms of maven modules.

Maven operates at build time, to compile and package the necessary artifacts (jars, wars…). Maven is the one that depends on the project structure.

Spring operates at runtime, once the applications is already built. The way it was built does not matter. What matters to Spring is the content of the resulting application classpath, which can absolutely be composed of multiple artifacts in the case of a multi-module project.

So yes, spring can work in a multi-module project, because it does not care about the structure of the project. It only needs the classpath to contain all required resources once the application is running.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement