Mastering Alibaba’s COLA: Clean Object‑Oriented Layered Architecture for Backend Services
COLA (Clean Object‑Oriented & Layered Architecture) is Alibaba’s open‑source framework that defines a structured, layered approach to reduce system entropy, offering both an architectural guide and a suite of reusable components—plus Maven archetypes and step‑by‑step commands to quickly generate and run a functional backend service.
What is COLA?
COLA stands for Clean Object‑Oriented & Layered Architecture. It is an open‑source application architecture from Alibaba, now at version 4.0.
Key Goals of COLA
Define a clean structural model.
Govern application complexity and reduce system entropy.
Transform chaotic codebases into orderly, maintainable systems.
The architecture consists of two parts: the COLA architecture itself and a set of COLA components.
COLA Architecture
The architecture provides best‑practice guidelines, including a layered package structure, business‑centric design, decoupled external dependencies, and separation of business and technical complexity.
COLA Components
COLA offers reusable components that boost development efficiency, such as:
cola-component-dto – defines DTO formats, including pagination.
cola-component-exception – standardizes exception handling with BizException and SysException.
cola-component-statemachine – a state‑machine utility.
cola-component-domain-starter – Spring‑managed domain entity starter.
cola-component-catchlog-starter – exception and logging support.
cola-component-extension-starter – extension point framework.
cola-component-test-container – testing container utilities.
Getting Started with COLA
Use the provided Maven archetypes to generate a project. For a web application, run:
mvn archetype:generate \
-DgroupId=com.alibaba.cola.demo.web \
-DartifactId=demo-web \
-Dversion=1.0.0-SNAPSHOT \
-Dpackage=com.alibaba.demo \
-DarchetypeArtifactId=cola-framework-archetype-web \
-DarchetypeGroupId=com.alibaba.cola \
-DarchetypeVersion=4.0.1Then build and run the service:
Execute mvn install (add -DskipTests to skip tests).
Enter the start directory and run mvn spring-boot:run.
After a successful start, a simple REST endpoint is available at http://localhost:8080/helloworld.
This quick setup demonstrates how COLA can streamline backend development.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Programmer DD
A tinkering programmer and author of "Spring Cloud Microservices in Action"
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
