Skip to content

flyeric0212/scaffold-onion-architecture

Repository files navigation

洋葱架构脚手架项目

技术栈

  • JDK 11
  • Gradle 7.2
  • Spring Boot 2.5.6
  • Database Access - Spring Data JPA
  • Database Migration - Flyway
  • Integration Test - Docker Compose

架构说明

本项目代码结构参考 Onion Architecture,参考以下介绍:

分层结构说明

image-20211013181013502

package分层调用关系如下:

Architectures.LayeredArchitecture layeredArchitectureDelegate = layeredArchitecture()
        .layer(DOMAIN_MODEL_LAYER).definedBy(domainModelPackageIdentifiers)
        .layer(DOMAIN_SERVICE_LAYER).definedBy(domainServicePackageIdentifiers)
        .layer(APPLICATION_SERVICE_LAYER).definedBy(applicationPackageIdentifiers)
        .layer(ADAPTER_LAYER).definedBy(concatenateAll(adapterPackageIdentifiers.values()))
        .whereLayer(DOMAIN_MODEL_LAYER).mayOnlyBeAccessedByLayers(DOMAIN_SERVICE_LAYER, APPLICATION_SERVICE_LAYER, ADAPTER_LAYER)
        .whereLayer(DOMAIN_SERVICE_LAYER).mayOnlyBeAccessedByLayers(APPLICATION_SERVICE_LAYER, ADAPTER_LAYER)
        .whereLayer(APPLICATION_SERVICE_LAYER).mayOnlyBeAccessedByLayers(ADAPTER_LAYER)
        .withOptionalLayers(optionalLayers);    

主要是为了隔离代码的传播,实现高内聚低耦合。

测试策略和结构参考:

本地构建

启动依赖

docker-compose up -d

也可以使用命令:

./gradlew composeUp
./gradlew composeDown 

编译

./gradlew clean build 

或者

./gradlew clean composeUp build composeDown

运行

./gradlew bootRun

修复代码格式

./gradlew spotlessApply

其他

CI流水线

参考.github/workflows下的ci.yaml文件

Swagger访问地址

本地启动后,访问如下地址: http://localhost:8082/swagger-ui/ 这里本地的端口是8082,可以根据自己项目实际情况调整

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published