{"id":13602065,"url":"https://github.com/alibaba/COLA","last_synced_at":"2025-04-11T08:31:23.279Z","repository":{"id":37285628,"uuid":"120463532","full_name":"alibaba/COLA","owner":"alibaba","description":"🥤 COLA: Clean Object-oriented \u0026 Layered Architecture","archived":false,"fork":false,"pushed_at":"2024-11-26T06:26:09.000Z","size":3805,"stargazers_count":12333,"open_issues_count":89,"forks_count":3147,"subscribers_count":345,"default_branch":"master","last_synced_at":"2025-04-08T06:22:15.860Z","etag":null,"topics":["architecture","clean","cola"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-2.1","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alibaba.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2018-02-06T13:46:27.000Z","updated_at":"2025-04-08T06:11:18.000Z","dependencies_parsed_at":"2024-01-13T17:49:21.792Z","dependency_job_id":"12c9ae32-760f-4cc0-a254-71d002190909","html_url":"https://github.com/alibaba/COLA","commit_stats":{"total_commits":335,"total_committers":37,"mean_commits":9.054054054054054,"dds":0.6507462686567165,"last_synced_commit":"ca12d5fb8a84c580c38e0a74f300720a2962f8db"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alibaba%2FCOLA","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alibaba%2FCOLA/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alibaba%2FCOLA/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alibaba%2FCOLA/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alibaba","download_url":"https://codeload.github.com/alibaba/COLA/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248361530,"owners_count":21090921,"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","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":["architecture","clean","cola"],"created_at":"2024-08-01T18:01:13.357Z","updated_at":"2025-04-11T08:31:21.811Z","avatar_url":"https://github.com/alibaba.png","language":"Java","readme":"# 🥤 COLA v5\n\n[![Fast CI](https://img.shields.io/github/actions/workflow/status/alibaba/cola/ci.yaml?branch=master\u0026logo=github\u0026logoColor=white\u0026label=fast%20ci)](https://github.com/alibaba/cola/actions/workflows/ci.yaml)\n[![Multiply Java versions CI](https://img.shields.io/github/actions/workflow/status/alibaba/cola/ci_by_multiply_java_versions.yaml?branch=master\u0026logo=github\u0026logoColor=white\u0026label=strong%20ci)](https://github.com/alibaba/cola/actions/workflows/ci_by_multiply_java_versions.yaml)\n[![License](https://img.shields.io/badge/license-LGPL--2.1-4EB1BA.svg?color=4D7A97\u0026logo=apache)](LICENSE)\n[![Java support](https://img.shields.io/badge/Java-17+-339933?logo=OpenJDK\u0026logoColor=white)](https://openjdk.java.net/)\n[![Maven Central](https://img.shields.io/maven-central/v/com.alibaba.cola/cola-component-dto.svg?logo=apache-maven\u0026label=maven%20central)](https://central.sonatype.com/namespace/com.alibaba.cola)\n[![GitHub Releases](https://img.shields.io/github/release/alibaba/COLA.svg)](https://github.com/alibaba/COLA/releases)\n[![GitHub Stars](https://img.shields.io/github/stars/alibaba/COLA?style=flat)](https://github.com/alibaba/COLA/stargazers)\n[![GitHub Forks](https://img.shields.io/github/forks/alibaba/COLA?style=flat)](https://github.com/alibaba/COLA/fork)\n[![user repos](https://badgen.net/github/dependents-repo/alibaba/COLA?label=user%20repos)](https://github.com/alibaba/COLA/network/dependents)\n[![GitHub issues](https://img.shields.io/github/issues/alibaba/COLA.svg)](https://github.com/alibaba/COLA/issues)\n[![GitHub Contributors](https://img.shields.io/github/contributors/alibaba/COLA)](https://github.com/alibaba/COLA/graphs/contributors)\n[![gitpod: Ready to Code](https://img.shields.io/badge/Gitpod-ready%20to%20code-339933?label=gitpod\u0026logo=gitpod\u0026logoColor=white)](https://gitpod.io/#https://github.com/alibaba/COLA)\n\n\u003cstrong\u003eCOLA 是 Clean Object-Oriented and Layered Architecture的缩写，代表“整洁面向对象分层架构”。\n目前COLA已经发展到[COLA v5](#版本迭代)。\u003c/strong\u003e\n\n\u003e - 想了解更多COLA信息，请关注微信公众号：  \n\u003e \u003ca href=\"#dummy\"\u003e\u003cimg src=\"https://img-blog.csdnimg.cn/2020110314110321.png\" width=\"25%\" alt=\"qrcode\" /\u003e\u003c/a\u003e\n\u003e - 想了解更多COLA背后的故事，请支持我的新书[《程序员的底层思维》](https://item.jd.com/13652002.html)\n\nCOLA分为两个部分，COLA架构和COLA组件。\n\n# 一、COLA架构\n\n## COLA 概述\n\n**架构**的**意义** 就是 要素结构：\n\n- 要素 是 组成架构的重要元素；\n- 结构 是 要素之间的关系。\n\n而 **应用架构**的**意义** 就在于\n\n- 定义一套良好的结构；\n- 治理应用复杂度，降低系统熵值；\n- 从随心所欲的混乱状态，走向井井有条的有序状态。\n\n\u003ca href=\"#dummy\"\u003e\u003cimg src=\"https://img-blog.csdnimg.cn/e27c22d706084ead900c8838326135f3.png\" alt=\"arch why\" /\u003e\u003c/a\u003e\n\nCOLA架构就是为此而生，其核心职责就是定义良好的应用结构，提供最佳应用架构的最佳实践。通过不断探索，我们发现良好的分层结构，良好的包结构定义，可以帮助我们治理混乱不堪的业务应用系统。\n\n\u003ca href=\"#dummy\"\u003e\u003cimg src=\"https://img-blog.csdnimg.cn/2020120918285068.png\" alt=\"cure\" /\u003e\u003c/a\u003e\n\n经过多次迭代，我们定义出了相对稳定、可靠的应用架构：\n\n\u003ca href=\"#dummy\"\u003e\u003cimg src=\"https://img-blog.csdnimg.cn/6549230c6723448fb3ab51ca74829e80.png\" alt=\"cola arch\" /\u003e\u003c/a\u003e\n\n## COLA Archetypes\n\n好的应用架构，都遵循一些共同模式，不管是六边形架构、洋葱圈架构、整洁架构、还是COLA架构，**都提倡以业务为核心，解耦外部依赖，分离业务复杂度和技术复杂度等**。\n\nCOLA架构区别于这些架构的地方，在于除了思想之外，我们还提供了可落地的工具和实践指导。\n\n为了能够快速创建满足COLA架构的应用，我们提供了两个`archetype`，位于[`cola-archetypes`目录](cola-archetypes)下：\n\n1. `cola-archetype-service`：用来创建纯后端服务的`archetype`。\n2. `cola-archetype-web`：用来创建`adapter`和后端服务一体的`web`应用`archetype`。\n\n# 二、COLA组件\n\n此外，我们还提供了一些非常有用的通用组件，这些组件可以帮助我们提升研发效率。\n\n这些功能组件被收拢在[`cola-components`目录](cola-components)下面。到目前为止，我们已经沉淀了以下组件：\n\n组件名称 | 功能 | 依赖\n------ | ---- | ----\n`cola-component-dto` | 定义了`DTO`格式，包括分页 |无\n`cola-component-exception` | 定义了异常格式，\u003cbr\u003e主要有`BizException`和`SysException` |无\n`cola-component-statemachine` | 状态机组件 | 无\n`cola-component-domain-starter` | `Spring`托管的领域实体组件 | 无\n`cola-component-catchlog-starter` | 异常处理和日志组件 | `exception`、`dto`组件\n`cola-component-extension-starter` | 扩展点组件 | 无\n`cola-component-test-container` | 测试容器组件 | 无\n\n# 三、如何使用COLA\n\n## 1. 创建应用\n\n执行以下命令：\n\n```bash\nmvn archetype:generate \\\n    -DgroupId=com.alibaba.cola.demo.web \\\n    -DartifactId=demo-web \\\n    -Dversion=1.0.0-SNAPSHOT \\\n    -Dpackage=com.alibaba.demo \\\n    -DarchetypeArtifactId=cola-framework-archetype-web \\\n    -DarchetypeGroupId=com.alibaba.cola \\\n    -DarchetypeVersion=5.0.0\n```\n\n命令执行成功的话，会看到如下的应用代码结构：\n\n\u003ca href=\"#dummy\"\u003e\u003cimg src=\"https://img-blog.csdnimg.cn/20201209192258840.png\" alt=\"demo struture\" /\u003e\u003c/a\u003e\n\n## 2. 运行应用\n\n- 在`项目`目录下运行`mvn install`（如果不想运行测试，可以加上`-DskipTests`参数）。\n- 进入`start`目录，执行`mvn spring-boot:run`。  \n  运行成功的话，可以看到`SpringBoot`启动成功的界面。\n- 生成的应用中，已经实现了一个简单的`Rest`请求，可以在浏览器中输入 http://localhost:8080/helloworld 进行测试。\n\n如果要生成不是`web`工程而是`service`工程也类似，执行的是下面的命令：\n\n```bash\nmvn archetype:generate \\\n    -DgroupId=com.alibaba.cola.demo.service \\\n    -DartifactId=demo-service \\\n    -Dversion=1.0.0-SNAPSHOT \\\n    -Dpackage=com.alibaba.demo \\\n    -DarchetypeArtifactId=cola-framework-archetype-service \\\n    -DarchetypeGroupId=com.alibaba.cola \\\n    -DarchetypeVersion=5.0.0\n```\n\n# 版本迭代\n\n## 5.0.0 版本\n1. 支持jdk17和SpringBoot 3.x\n2. 增加cola-archetype-light，支持新的基于package轻量级分层架构\n3. 增加cola-component-unittest组件，支持[新的单元测试](https://blog.csdn.net/significantfrank/article/details/137495244)\n4. 增强cola-component-test-container组件，支持Junit5的Extension\n\n\n## 4.0.0 版本\n\nhttps://blog.csdn.net/significantfrank/article/details/110934799\n\n## 3.1.0 版本\n\nhttps://blog.csdn.net/significantfrank/article/details/109529311\n\n1. 进一步简化了`cola-core`，只保留了扩展能力。\n2. 将`exception`从`cola-core`移入到`cola-common`。\n3. 对`archetype`中的分包逻辑进行重构，改成按照`domain`做划分。\n4. 将`cola-archetype-web`中的`controller`改名为`adapter`，为了呼应六边形架构的命名。\n\n## 3.0.0 版本\n\nhttps://blog.csdn.net/significantfrank/article/details/106976804\n\n## 2.0.0 版本\n\nhttps://blog.csdn.net/significantfrank/article/details/100074716\n\n## 1.0.0 版本\n\nhttps://blog.csdn.net/significantfrank/article/details/85785565\n\n\n","funding_links":[],"categories":["Java","学习资料","框架","🔧 Utilities \u0026 Miscellaneous","白盒测试","开发框架"],"sub_categories":["FPS","常见开发框架"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falibaba%2FCOLA","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falibaba%2FCOLA","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falibaba%2FCOLA/lists"}