Last updated: 2026-11-10

  1. Learn
  2. ›
  3. Multi-Module
  4. ›
  5. Modulith vs Multi-Module

Spring Modulith vs Multi-Module projects - advantages and disadvantages

Clear module boundaries help us maintain a growing Spring Boot application. For a shop with product, inventory and order features, we compare Spring Modulith packages with Maven or Gradle subprojects.

Spring Modulith and Multi-Module explained

With Spring Modulith, the main focus is on splitting the actual Java or Kotlin code into modules. Under a main package (for example my/company/app) direct subpackages are treated as modules (for example product, inventory). Other modules should access the exposed API, usually public types in the module's base package or explicitly named interfaces. Internal subpackages are not part of that API. This is an architecture rule, not a separate Java compiler boundary.

A test calling ApplicationModules.of(Application.class).verify() checks for cycles and access to internal packages. Merely adding the dependency does not enforce these rules. See module verification. Other artifacts are taken from src/main/resources, just like in a monolith. With this approach, practically all external libraries of the application can be used without restrictions.

Multi-module projects are based on the native ability of Gradle or Maven to manage multiple subprojects and integrate them into the build process using the Spring Boot plugin. Each module has its own folder in the project (for example app/product, app/inventory) and each module has its own src/main/java (or src/main/kotlin) and src/main/resources folders. These modules are built as real jars - in the final executable fat jar, all other libraries are included again.

Differences in practice

For an existing application, we first group related code into domain packages and add module verification. The effort depends on existing coupling: references to internal classes and dependency cycles need to be resolved before the checks pass.

For multi-module projects, no additional library is required, but the build files (build.gradle, build.gradle.kts or pom.xml) need much more adjustment. Access is only possible along the defined dependency path - imports outside of the integrated modules are technically not possible. A build dependency exposes public classes on its classpath; it does not distinguish a module API from its internals. Package visibility and architecture tests can enforce additional boundaries.

For integration tests, we need to distinguish a module test from a full application test.

  • With Spring Modulith, @ApplicationModuleTest starts the current module in isolation by default. BootstrapMode.ALL_DEPENDENCIES includes its transitive dependencies, not necessarily the entire application. Use extraIncludes for additional modules needed by the scenario, or @SpringBootTest for a full application test. See the module testing documentation.
  • For multi-module projects, module dependencies are always explicitly defined in the build files (for example api project(':product') in a build.gradle). When integration tests with @SpringBootTest are run, the application automatically starts with the context available for that module. Since each module also provides its own resources, only those are actually available (for example, only the included Flyway scripts are executed).

Some libraries also require additional configuration to operate in a multi-module setup. Check how each library discovers resources from dependency JARs. For jte, template compilation and the packaged template classes need to be included in the build of the relevant modules.

Choosing an approach

Both approaches can help us separate responsibilities inside a monolithic application. Neither guarantees maintainability: the value comes from boundaries that reflect the domain and remain easy to understand. In both cases, it is important to design the module structure around your domain, not around technical layers - so better product, inventory, order instead of services, controller, frontend. More details in best practices for multi-module projects.

Spring Modulith differs less from a monolith, so the learning and configuration effort is smaller. Interfaces need to be clearly defined, which can be either an advantage or a disadvantage. A special test can also generate documentation of the current module structure.

The higher setup effort of multi-module projects gives each module its own build artifact and resources. All artifacts are directly assigned to a module, making it easier to split work within a team. The code itself is not aware of the modules, since the structure is managed by Maven or Gradle.

Overview of modularization options in Spring Boot

Overview of modularization options in Spring Boot

The overview is a simplified comparison: a monolith can already have well-structured packages, and Spring Modulith still produces a single application. Its interface rules are checked by verification tests; separate build modules restrict the available classpath.

In both approaches, individual modules can later be separated into microservices if needed. However, this step should be carefully considered - architecture is not an end in itself, but the added benefits should clearly outweigh the new costs.

For our shop, the first decision is which responsibilities belong to product, inventory and order. Package rules or separate build artifacts then help us keep those boundaries explicit.

In the Bootify Builder, you can create a modularized Spring Boot app using either Spring Modulith or the multi-module approach. Define your custom module structure, including the assignments of entities and Spring Security configs, and get the full setup directly in the browser.

See Pricing
or read quickstart