2. Verifying Application Module Structure

We can verify whether our code arrangement adheres to the intended constraints by calling the ….verify() method on our ApplicationModules instance:spring-doc.cn

ApplicationModules.of(Application.class).verify();

The verification includes the following rules:spring-doc.cn

  • No cycles on the application module level — the dependencies between modules have to form directed, acyclic graph.spring-doc.cn

  • Efferent module access via API packages only — All references to types that reside in application module internal packages are rejected. See Advanced Application Modules for details.spring-doc.cn

  • Explicitly allowed application module dependencies only (optional) — An application module can optionally define allowed dependencies via @ApplicationModule(allowedDependencies = …). If those are configured, dependencies to other application modules are rejected. See Explicit Application Module Dependencies and Named Interfaces for details.spring-doc.cn

Spring Modulith optionally integrates with the jMolecules ArchUnit library and, if present, automatically triggers its Domain-Driven Design verification rules described here.spring-doc.cn