Spring ModulithSpring Modulith1.3.5

Spring Modulith 允许开发者构建结构良好的 Spring Boot 应用程序,并引导开发者查找和使用由领域驱动的应用程序模块。 它支持此类模块化安排的验证、各个模块的集成测试、在模块级别观察应用程序的行为以及基于创建的安排创建文档片段

快速入门

  1. https://start.spring.io 上创建一个 Spring Boot 应用程序

  2. 创建一个 Java 包安排,将业务模块作为应用程序主包的直接子包

    □ Example
    └─ □ src/main/java
       ├─ □ example           <1>
       │  └─ Application.java
       ├─ □ example.inventory <2>
       │  └─ …
       └─ □ example.order     <2>
          └─ …
    
    1. 应用程序根包

    2. 应用程序模块包

  3. 创建 一个 ApplicationModules 模型,运行验证,并创建文档片段

    class ApplicationTests {
    
      @Test
      void writeDocumentationSnippets() {
    
        var modules = ApplicationModules.of(Application.class).verify(); (1)
    
        new Documenter(modules) (2)
          .writeModulesAsPlantUml()
          .writeIndividualModulesAsPlantUml();
      }
    }
    
    1. 创建应用程序模块模型并验证其结构

    2. Asciidoctor 片段(组件图、应用程序模块画布)渲染到 target/modulith-docs

  4. 为各个应用程序模块运行集成测试

    □ Example
    └─ □ src/test/java
       └─ □ example.order
          └─ OrderModuleIntegrationTests.java
    
    @ApplicationModuleTests
    class OrderModuleIntegrationTests {
    
      @Test
      void someTestMethod() { … }
    }
    
Spring Initializr

快速启动您的项目

更进一步

VMware 提供培训和认证,以加速您的进度。

了解更多

获得支持

Tanzu Spring 在一个简单的订阅中提供对 OpenJDK™、Spring 和 Apache Tomcat® 的支持和二进制文件。

了解更多

即将举行的活动

查看 Spring 社区中所有即将举行的活动。

查看所有