前言介绍

COLA既是框架,也是架构。创建COLA的主要目的是为应用架构提供一套简单的可以复制、可以理解、可以落地、可以控制复杂性的”指导和约束”。
源码地址: https://github.com/alibaba/COLA

快速启动示例项目craftsman

  • 在本地新建craftsman的数据库,项目用的mysql driver是8.0的,所以可以使用mysql8
  • 执行resource下的TableCreationDDL.sql,创建项目的表,共两张表
  • 修改application.properties的配置文件的mysql用户名和密码
  • 修改MetricDO类,新增两个属性(我的版本要加你看下你跑案例会不会报错)

    1. private String creator="tangzihao";
    2. private String modifier = "tangzihao";
  • 需要在表user_profile中插数据

  • 执行Application.java就好了

    craftsman项目启动后测试

    /metrics/ata的post方法测试

    使用postman

  • 方法 post

  • 路径: localhost:8080/metrics/ata
  • 请求体:

    1. {
    2. "ataMetricCO": {
    3. "title":"母猪的产后护理",
    4. "url":"https://www.google.com/search?q=%E7%A6%85%E4%B8%8E%E6%91%A9%E6%89%98%E8%BD%A6%E7%BB%B4%E4%BF%AE%E7%9A%84%E8%89%BA%E6%9C%AFpdf&oq=%E7%A6%85%E4%B8%8E%E6%91%A9%E6%89%98%E8%BD%A6&aqs=chrome.1.69i57j35i39j0l6.6603j0j4&sourceid=chrome&ie=UTF-8",
    5. "thumbsUpCount":10,
    6. "hitCount":1000,
    7. "commentCount":100,
    8. "favoriteCount":20,
    9. "ownerId":"123456"
    10. },
    11. "operater": "tangzihao",
    12. "needsOperator": true
    13. }

    metrics/ata get方法测试

  • 方法: get

  • 路径: localhost:8080/metrics/ata?ownerId=123456

    模块介绍

    各个模块介绍

    | app模块 | client模块 | controller模块 | domain模块 | infrastructure模块 | start模块 | | command | api | 和一般的controller一样 | 领域对象 | common | 启动类 | | —- | —- | —- | —- | —- | —- | | handler | dto | | domain factory | config 需要注入Bootstrap的bean | | | service | context | | | tunnel mapper和rpc | | | | | | | converter | |

pom文件依赖关系

  • start依赖controller
  • controller依赖app
  • app依赖
    • client
    • infrastructure
  • infrastructure
    • domain
  • domain
    • cola-core
    • client
  • client

    • cola-common

      源码分析

      boot启动流程分析

  • 扫描到bootstrap类型的bean,执行其init方法 Cola4.0框架使用 - 图1

  • bootstrap的init方法执行 Cola4.0框架使用 - 图2

    查询流程分析

    Cola4.0框架使用 - 图3