Verifying Application Module Structure
-
仅允许明确定义的应用模块依赖关系(可选)。
-
可选择与 ArchUnit 集成,以自动执行特定于域驱动设计的验证规则。
我们可以通过调用`ApplicationModules`实例上的`….verify()`方法来验证我们的代码排列是否符合预期的约束:
We can verify whether our code arrangement adheres to the intended constraints by calling the ….verify()
method on our ApplicationModules
instance:
-
Java
-
Kotlin
ApplicationModules.of(Application.class).verify();
ApplicationModules.of(Application::class).verify()
验证包括以下规则:
The verification includes the following rules:
-
No cycles on the application module level — the dependencies between modules have to form directed, acyclic graph.
-
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.
-
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 Modulith 可选择与 jMolecules ArchUnit 库集成,并在存在时自动触发其描述的 here 的领域驱动设计验证规则。
Spring Modulith optionally integrates with the jMolecules ArchUnit library and, if present, automatically triggers its Domain-Driven Design verification rules described here.