領先一步
VMware 提供培訓和認證,助您加速進步。
瞭解更多Spring Modulith 允許開發者構建結構良好的 Spring Boot 應用程式,並指導開發者如何發現和使用由領域驅動的應用程式模組。它支援驗證此類模組化安排,整合測試單個模組,在模組級別觀察應用程式行為,並根據所建立的安排生成文件片段。
在 https://start.spring.io 建立一個 Spring Boot 應用程式
建立 Java 包結構,將業務模組作為應用程式主包的直接子包。
□ Example
└─ □ src/main/java
├─ □ example <1>
│ └─ Application.java
├─ □ example.inventory <2>
│ └─ …
└─ □ example.order <2>
└─ …
應用程式根包
應用程式模組包
建立一個 ApplicationModules 模型,執行驗證並建立文件片段。
class ApplicationTests {
@Test
void writeDocumentationSnippets() {
var modules = ApplicationModules.of(Application.class).verify(); (1)
new Documenter(modules) (2)
.writeModulesAsPlantUml()
.writeIndividualModulesAsPlantUml();
}
}
建立應用程式模組模型並驗證其結構。
將Asciidoctor 片段(元件圖、應用程式模組畫布)渲染到 target/modulith-docs。
對單個應用程式模組執行整合測試。
□ Example
└─ □ src/test/java
└─ □ example.order
└─ OrderModuleIntegrationTests.java
@ApplicationModuleTests
class OrderModuleIntegrationTests {
@Test
void someTestMethod() { … }
}