Spring Modulith
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, integration testing individual modules, observing the applicationโs behavior on the module level and creating documentation snippets based on the arrangement created.
Quickstart
-
Create a Spring Boot application on https://start.spring.io
-
Add Spring Modulith to your application by adding this to your
pom.xml
:<!-- The Maven repository to pull the dependencies from --> <repositories> <repository> <id>spring-snapshots</id> <url>https://repo.spring.io/snapshot</url> </repository> </repositories> <!-- Include the BOM for simplified version management --> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.modulith</groupId> <artifactId>spring-modulith-bom</artifactId> <version>1.0.0-SNAPSHOT</version> <scope>import</scope> <type>pom</type> </dependency> </dependencies> </dependencyManagement> <dependencies> <!-- The test dependency to pull in verification APIs --> <dependency> <groupId>org.springframework.modulith</groupId> <artifactId>spring-modulith-starter-test</artifactId> <scope>test</scope> </dependency> </dependencies>
-
Create a Java package arrangement that puts business modules as direct sub-packages of the applicationโs main package.
โก Example โโ โก src/main/java โโ โก example <1> | โโ Application.java โโ โก example.inventory <2> | โโ โฆ โโ โก example.order <2> โโ โฆ
-
The application root package
-
Application module packages
-
-
Create an
ApplicationModules
model, run verifications and create documentation snippets.class ApplicationTests { @Test void writeDocumentationSnippets() { var modules = ApplicationModules.of(Application.class).verify(); (1) new Documenter(modules) (2) .writeModulesAsPlantUml() .writeIndividualModulesAsPlantUml(); } }
-
Creates application module model and verifies its structure.
-
Renders Asciidoctor snippets (component diagrams, application module canvas) to
target/modulith-docs
.
-
-
Run integration tests for individual application modules.
โก Example โโ โก src/test/java โโ โก example.order โโ OrderModuleIntegrationTests.java
@ApplicationModuleTests class OrderModuleIntegrationTests { @Test void someTestMethod() { โฆ } }
Reference documentation
Find the reference documentation here.
Contributing
Pull requests are welcome. Note, that we expect everyone to follow the code of conduct.
License
Spring Modulith is Open Source software released under the Apache 2.0 license.