Upgrade to Pro — share decks privately, control downloads, hide ads and more …

What's new in Spring Modulith?

What's new in Spring Modulith?

Spring Modulith is a relatively new addition to the Spring ecosystem and guides developers in structuring their applications to create more maintainable software.

This talk briefly introduces the ideas of the project, and casts light on the features of the most recent releases, the new 2.0 major version coming in November in particular. Highlights include the revamped event publication registry, advanced C4 model integration, and significantly overhauled observability and actuator support.

Avatar for Oliver Drotbohm

Oliver Drotbohm

October 09, 2025
Tweet

More Decks by Oliver Drotbohm

Other Decks in Programming

Transcript

  1. “Spring Modulith allows developers to build well-structured Spring Boot applications

    and guides developers in finding and working with application modules driven by the domain. It supports the verification of such modular arrangements, testing individual modules, integrating them in eventually- consistent way, observing the application’s behavior on the module level, and creating documentation snippets based on the arrangement created. — Spring Modulith project page
  2. My Module Provided Interface Required Interface All public types in

    the module's base package All dependencies to types in other modules My Module Named Interface A named set of types located anywhere inside the module. API SPI mymodule :" api mymodule :" spi Explicit references
  3. import org.springframework.modulith.NamedInterface; @NamedInterface("api") public interface PaymentService { CreditCardPayment pay(Order order,

    CreditCardNumber creditCardNumber); Optional<Payment<?>$ getPaymentFor(Order order); Optional<Receipt> takeReceiptFor(Order order); } 1.4 2.0 api api - PaymentService - CreditCardPayment - CreditCardNumber - Order - Payment - PaymentService - Receipt // from spring-modulith-api artifact
  4. A B C D E Change detected in C. We

    need to test C and A!
  5. Change-Aware Test Execution  All tests are executed if… -

    No changes at all - Non-module files have been changed (e.g., pom.xml)  Individual tests are executed if… - They're directly or transitively affected by a change (by default: uncommitted or unpushed, customizable)  CI Integration - Diff anchor configurable via environment variable
  6. @Service @RequiredArgsConstructor class Checkout { private final OrderRepository orders; private

    final ApplicationEventPublisher events; @Transactional void complete(Order order) { orders.save(order.complete()); events.publishEvent( OrderCompleted.of(order.getId())); } } @Service class Inventory { @ApplicationModuleListener void on(OrderCompleted event) { /& Update inventory } }
  7. Event Publication Published / Processing Completed  Listener  Event

    How do we distinguish processing from failed events? How do we handle resubmissions in multi-instance setups? Application Listener Decoration !
  8. Completed Published Resubmitted Processing Failed 2.0 Application Code Application Listener

    Decoration !  Additional properties - Number of completion attempts - Last resubmission date
  9. #

  10.  Runtime Support - Extended module metadata in application-modules.json -

    Improved bootstrap procedure - Structural verification on startup - Revamped observability support, incl. automatic metrics for cross-module event counters  Event Publication Registry - Extended lifecycle - Staleness monitor API  Tool integration - IDEA, VSCode. Eclipse coming.  Application Module Model - Nested Application Modules - Propagating named interface declarations  Verification - VerificationOptions to customize verifications and plug additional ArchUnit rules  Testing - Change-aware test execution - Support for beans contained in test sources  Documentation - Visibility improvements in module canvas - Creates application-modules.json 1.3 2.0 1.4 Summary 2.0 2.0 2.0 2.0 1.3 2.0 1.4 1.4 1.4 1.4
  11. Outlook  C4 model integration  Module-aware database migrations 

    Failure signals from module listeners  Violation freeze