{"id":26816202,"url":"https://github.com/flyeric0212/scaffold-onion-architecture","last_synced_at":"2025-10-27T23:39:21.837Z","repository":{"id":144569079,"uuid":"386503168","full_name":"flyeric0212/scaffold-onion-architecture","owner":"flyeric0212","description":null,"archived":false,"fork":false,"pushed_at":"2025-06-18T10:29:14.000Z","size":262,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-27T23:39:21.128Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flyeric0212.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-07-16T04:00:25.000Z","updated_at":"2025-06-18T10:29:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"d856e0c7-20b2-4220-8cdf-f5ca639be6f0","html_url":"https://github.com/flyeric0212/scaffold-onion-architecture","commit_stats":null,"previous_names":["flyeric0212/scaffold-onion-architecture"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/flyeric0212/scaffold-onion-architecture","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flyeric0212%2Fscaffold-onion-architecture","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flyeric0212%2Fscaffold-onion-architecture/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flyeric0212%2Fscaffold-onion-architecture/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flyeric0212%2Fscaffold-onion-architecture/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flyeric0212","download_url":"https://codeload.github.com/flyeric0212/scaffold-onion-architecture/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flyeric0212%2Fscaffold-onion-architecture/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281361397,"owners_count":26487881,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-27T02:00:05.855Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-30T03:18:16.499Z","updated_at":"2025-10-27T23:39:21.832Z","avatar_url":"https://github.com/flyeric0212.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 洋葱架构脚手架项目\n\n- [洋葱架构脚手架项目](#洋葱架构脚手架项目)\n  - [技术栈](#技术栈)\n  - [架构说明](#架构说明)\n  - [分层结构说明](#分层结构说明)\n  - [本地构建](#本地构建)\n    - [启动依赖](#启动依赖)\n    - [编译](#编译)\n    - [运行](#运行)\n    - [修复代码格式](#修复代码格式)\n  - [其他](#其他)\n    - [CI流水线](#CI流水线)\n    - [Swagger访问地址](#Swagger访问地址)\n\n## 技术栈\n\n- JDK 11\n- Gradle 7.2\n- Spring Boot 2.5.6\n- Database Access - Spring Data JPA\n- Database Migration - Flyway\n- Integration Test - Docker Compose\n\n## 架构说明\n本项目代码结构参考 Onion Architecture，参考以下介绍:\n* [The Onion Architecture : part 1](https://jeffreypalermo.com/2008/07/the-onion-architecture-part-1/)\n* [The Onion Architecture : part 2](https://jeffreypalermo.com/2008/07/the-onion-architecture-part-2/)\n* [The Onion Architecture : part 3](https://jeffreypalermo.com/2008/08/the-onion-architecture-part-3/)\n* [The Onion Architecture : part 4](https://jeffreypalermo.com/2013/08/onion-architecture-part-4-after-four-years/)\n\n* [ArchUnit Onion Architecture](https://www.archunit.org/userguide/html/000_Index.html#_architectures)\n\n## 分层结构说明\n\n![image-20211013181013502](images/ddd-onion-architecture.png)\n\npackage分层调用关系如下：\n```\nArchitectures.LayeredArchitecture layeredArchitectureDelegate = layeredArchitecture()\n        .layer(DOMAIN_MODEL_LAYER).definedBy(domainModelPackageIdentifiers)\n        .layer(DOMAIN_SERVICE_LAYER).definedBy(domainServicePackageIdentifiers)\n        .layer(APPLICATION_SERVICE_LAYER).definedBy(applicationPackageIdentifiers)\n        .layer(ADAPTER_LAYER).definedBy(concatenateAll(adapterPackageIdentifiers.values()))\n        .whereLayer(DOMAIN_MODEL_LAYER).mayOnlyBeAccessedByLayers(DOMAIN_SERVICE_LAYER, APPLICATION_SERVICE_LAYER, ADAPTER_LAYER)\n        .whereLayer(DOMAIN_SERVICE_LAYER).mayOnlyBeAccessedByLayers(APPLICATION_SERVICE_LAYER, ADAPTER_LAYER)\n        .whereLayer(APPLICATION_SERVICE_LAYER).mayOnlyBeAccessedByLayers(ADAPTER_LAYER)\n        .withOptionalLayers(optionalLayers);\n```\n主要是为了隔离代码的传播，实现高内聚低耦合。\n\n测试策略和结构参考:\n* [Testing Strategies in a Microservices Architecture](https://martinfowler.com/articles/microservice-testing)\n* [Unit and Integration Tests for RestControllers in Spring Boot](https://thepracticaldeveloper.com/2017/07/31/guide-spring-boot-controller-tests)\n\n## 本地构建\n\n### 启动依赖\n```\ndocker-compose up -d\n```\n也可以使用命令：\n```\n./gradlew composeUp\n./gradlew composeDown\n```\n\n### 编译\n```\n./gradlew clean build\n\n或者\n\n./gradlew clean composeUp build composeDown\n```\n\n### 运行\n```\n./gradlew bootRun\n```\n\n### 修复代码格式\n```\n./gradlew spotlessApply\n```\n\n## 其他\n\n### CI流水线\n参考.github/workflows下的ci.yaml文件\n\n### Swagger访问地址\n本地启动后，访问如下地址：\nhttp://localhost:8082/swagger-ui/\n这里本地的端口是8082，可以根据自己项目实际情况调整","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflyeric0212%2Fscaffold-onion-architecture","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflyeric0212%2Fscaffold-onion-architecture","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflyeric0212%2Fscaffold-onion-architecture/lists"}