- JDK 11
- Gradle 7.2
- Spring Boot 2.5.6
- Database Access - Spring Data JPA
- Database Migration - Flyway
- Integration Test - Docker Compose
本项目代码结构参考 Onion Architecture,参考以下介绍:
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);
主要是为了隔离代码的传播,实现高内聚低耦合。
测试策略和结构参考:
- Testing Strategies in a Microservices Architecture
- Unit and Integration Tests for RestControllers in Spring Boot
docker-compose up -d
也可以使用命令:
./gradlew composeUp
./gradlew composeDown
./gradlew clean build
或者
./gradlew clean composeUp build composeDown
./gradlew bootRun
./gradlew spotlessApply
参考.github/workflows下的ci.yaml文件
本地启动后,访问如下地址: http://localhost:8082/swagger-ui/ 这里本地的端口是8082,可以根据自己项目实际情况调整