1 Star 0 Fork 21

陈帅兵 / maozi-cloud-parent

forked from maozi / maozi-cloud-parent 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

脚手架说明

该脚手架基于微服务开发,给开发人员快速投入业务开发,封装好了一系列的组件入:日志收集、业务通用方法、框架配置、数据包结果集、监控、常用的第三方接口 等一系列功能,后续会不断升级 框架组件、封装更多通用方法或框架组件、第三方接口、接入Kubesphere Istio

已有三家公司在用的脚手架,每次更新发版都会经过集成的框架基本可用 压测,请放心使用,有问题请咨询QQ1095071913

架构图


目录说明


maozi-cloud-common
  maozi-cloud-common-tool                 (工具)
  maozi-cloud-common-generate-code        (代码生成工具)
  
  
  
maozi-cloud-config
  maozi-cloud-config-apollo               (Apollo配置)
  maozi-cloud-config-arthas               (Arthas配置)
  maozi-cloud-config-bootadmin            (SpringBootAdmin配置)
  maozi-cloud-config-db                   (数据库配置)
  maozi-cloud-config-discovery            (注册中心配置)
  maozi-cloud-config-dubbo                (Dubbo配置)
  maozi-cloud-config-feign                (Feign配置)
  maozi-cloud-config-job                  (XXL-Job配置)
  maozi-cloud-config-log                  (日志配置)
  maozi-cloud-config-mvc                  (Controller配置)
  maozi-cloud-config-redis                (Redis配置)
  maozi-cloud-config-seata                (Seata配置)
  maozi-cloud-config-sentinel             (Sentinel配置)
  maozi-cloud-config-sentry               (Sentry配置)
  maozi-cloud-config-sso                  (单点登录权限配置)
  maozi-cloud-config-stream               (MQ Stream配置)
  maozi-cloud-config-swagger              (接口文档配置)
  
  
  
maozi-cloud-entity
  maozi-cloud-base-entity
    maozi-cloud-base-do                   (Domain Object 基层)
    maozi-cloud-base-dto                  (Data Transfer Object 基层)
    maozi-cloud-base-enum                 (枚举 基层)
    maozi-cloud-base-vo                   (View Object 基层)
  maozi-cloud-business-entity             
    maozi-cloud-do                        (Domain Object 聚合依赖)
      maozi-cloud-seata-do                (服务通用 Seata Domain)  
    maozi-cloud-dto                       (Data Transfer Object 聚合依赖)
      maozi-cloud-sso-oauth-dto           (授权服务 Data Transfer Object)
      maozi-cloud-system-user-dto         (系统用户服务 Data Transfer Object)
    maozi-cloud-enum                      (枚举 聚合依赖)
    maozi-cloud-result                    (结果集 基层)
    maozi-cloud-vo                        (View Object 聚合依赖)
  
  
  
maozi-cloud-service
  maozi-cloud-service-base
    maozi-cloud-service-base-api          (服务接口 基层)
    maozi-cloud-service-base-impl         (服务接口实现 基层)
    maozi-cloud-service-base-run          (启动服务 基层)
  maozi-cloud-service-db-impl             (服务聚合依赖 数据库基层版)
  maozi-cloud-service-business
    maozi-cloud-service-impl              (服务聚合依赖 基层)
      maozi-cloud-service-bd              (百度地图服务接口实现)
      maozi-cloud-service-qny             (七牛云服务接口实现)
      maozi-cloud-service-ss              (闪送服务接口实现)
      maozi-cloud-service-company-wechat  (企业微信服务接口实现)
    maozi-cloud-service-rest-api          (服务HTTP接口聚合依赖 基层)
    maozi-cloud-service-rpc-api           (服务RPC接口聚合依赖 基层)
  maozi-cloud-service-plugin
    maozi-cloud-service-db-impl           (数据库服务实现 插件基层)
  
  
  


集成框架版本说明

框架 版本 说明
JDK 17 兼容JDK8,由于Springboot3只支持17所以在Springboot2.6中先用
Spring Boot 2.6.11 基于Spring框架的快速开发应用程序框架
Spring Cloud 2021.0.4 Netfix推出微服务一站式服务框架
Spring Cloud Alibaba 2021.0.4.0 阿里巴巴推出微服务一站式服务框架
Spring Cloud Alibaba Dubbo 3.0.8 基于Triple Stream协议 对内 服务与服务之间RPC通信框架
Spring Cloud Feign 跟随SC版本 基于HTTP协议 对外 服务与第三方之间RPC通信框架
Spring Cloud Alibaba Gateway 跟随SCA版本 黑白名单,鉴权,流量分发 流式处理网关框架
Spring Cloud Alibaba Stream Rocketmq 跟随SCA版本 异步消峰消息框架
Spring Cloud Alibaba Seata 跟随SCA版本 分布式事务框架
Spring Cloud Alibaba Sentinel 跟随SCA版本 监控流量 限流 框架,个人二开支持数据持久化,限流规则持久化Nacos
Spring Cloud Alibaba Nacos 跟随SCA版本 分布式服务治理 配置中心 框架
Spring Boot Admin 2.6.9 基于Actuator分布式JVM监控框架
Spring Boot Oauth2 跟随SC版本 基于Oauth2协议授权服务器授权单点登录 权限 框架
Arthas Tunnel 3.6.7 远程进入服务JVM内部监控诊断
Skywalking 8.4.0 接口链路跟踪性能分析
Mybatis Plus Join 1.2.4 基于Mybatis Plus二开 关系型数据库对象关系映射框架 支持连表查询
Mybatis Plus Actable 1.5.0.RELEASE 关系型数据库对象关系映射 正向生成自动建表框架
Spring Flyway 跟随SB版本 初始化数据库数据
Knife4j 4.0.0 基于Swagger二开 接口文档可视化框架 个人二开新增枚举解析
XXL Job 2.3.0 定时任务框架


编译前准备


编译前说明


项目不要缺少.git文件 ,不然会编译不过

编译前要准备Nexus,既然是微服务那就要做远程仓库方便后续打包上线,如果只是想本地测试没有Nexus的话就不要走Maven Deploy编译

我们将会基于Docker来去安装中间件,本地测试的可以考虑安装一个Docker Desktop来进行测试使用,将开始逐步安装

Docker Desktop自带Docker Compose,安装K8s也非常方便简单



Windows11安装Docker Desktop


1. 安装WSL


wsl --install

# 若报错提示 “无法解析服务器的名称或地址”,则输入
# dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
# dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
# 还是一样则需要在网络和共享设置里,选择当前连接,设置IPv4的属性,更改DNS服务器 114.114.114.114
# 完成后再执行 
# wsl --update
# wsl --install

2. 安装Docker Desktop

游览器下载安装包 https://docs.docker.com/desktop/release-notes/#4163


3. 设置加速镜像仓库

安装完后打开面板点击登录旁边的setting设置,点击Docker Engine 输入

{
  "builder": {
    "gc": {
      "defaultKeepStorage": "20GB",
      "enabled": true
    }
  },
  "experimental": false,
  "features": {
    "buildkit": true
  },
  "registry-mirrors": [
    "https://pn1nqbsb.mirror.aliyuncs.com",
    "https://docker.mirrors.ustc.edu.cn",
    "https://kubernetes.github.io"
  ]
}



Docker Compose安装Nexus


1. 下载docker-compose.yml文件


2. 执行

docker-compose up -d


设置Maven Setting.xml文件

下载MavenSetting与你本地文件合并到一起,将文件中的 账号、密码、Nexus地址 修改好



若你的Nexus地址不是localhost:8081


打开项目Parent的Pom.xml文件,找到distributionManagement标签

    <distributionManagement>
        <repository>
            <id>nexus-releases</id>
            <name>Nexus Release Repository</name>
            <url>http://修改Nexus地址/repository/maven-releases/</url>
        </repository>
        <snapshotRepository>
            <id>nexus-snapshots</id>
            <name>Nexus Snapshot Repository</name>
            <url>http://修改Nexus地址/repository/maven-snapshots/</url>
        </snapshotRepository>
    </distributionManagement>


完成以上步骤即可编译 mvn clean deploy


测试脚手架前准备


编译后说明

Nacos版本固定2.0.4

该阶段围绕着安装Nacos、添加基础配置进行讲解,目前安装走的Docker Compose进行安装,没有docker的可以拉取Nacos官方代码进行启动,本文档跳过以下安装步骤,导入Nacos配置文件即可


Docker Compose安装Nacos


1.下载Nacos Docker安装目录


2.导入SQL脚本


3.在下载的GitHub项目上做修改

在env目录上修改nacos-standlone-mysql.env文件

PREFER_HOST_MODE=hostname
MODE=standalone
SPRING_DATASOURCE_PLATFORM=mysql
MYSQL_SERVICE_HOST=Mysql IP
MYSQL_SERVICE_DB_NAME=Nacos数据库名字
MYSQL_SERVICE_PORT=Mysql端口
MYSQL_SERVICE_USER=Mysql用户名 
MYSQL_SERVICE_PASSWORD=Mysql密码
MYSQL_SERVICE_DB_PARAM=characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false&serverTimezone=Asia/Shanghai

在example目录上修改standalone-mysql-8.yaml

若你的Mysql版本不是8就修改standalone-mysql-5.7.yaml


standalone-mysql-8.yaml

version: "2"
services:
  nacos:
    image: nacos/nacos-server:${NACOS_VERSION}
    container_name: nacos-standalone-mysql
    env_file:
      - ../env/nacos-standlone-mysql.env
    volumes:
      - ./standalone-logs/:/home/nacos/logs
      - ./init.d/custom.properties:/home/nacos/init.d/custom.properties
    ports:
      - "8848:8848"
      - "9848:9848"
      - "9555:9555"
    restart: always


standalone-mysql-5.7.yaml

version: "2"
services:
  nacos:
    image: nacos/nacos-server:${NACOS_VERSION}
    container_name: nacos-standalone-mysql
    env_file:
      - ../env/nacos-standlone-mysql.env
    volumes:
      - ./standalone-logs/:/home/nacos/logs
      - ./init.d/custom.properties:/home/nacos/init.d/custom.properties
    ports:
      - "8848:8848"
      - "9848:9848"
      - "9555:9555"
    restart: always


4.启动Nacos


执行

docker-compose -f example/standalone-mysql-8.yaml up -d


5.修改Nacos配置文件


若Nacos地址是localhost:8848即可忽然步骤


在Nacos配置中搜索

cloud-dubbo.yml

cloud-nacos.yml

将127.0.0.1:8848修改成Nacos地址




测试脚手架


测试项目可以用代码生成项目 或 从作者的仓库里找两个已经创建好的项目进行启动测试


业务项目:系统服务授权服务

中间件项目:网关服务监控服务流控服务

拉取代码后即可编译或启动项目 ,记住不要少了.git文件 不然会编译失败



创建新业务项目


生成代码

打开 maozi-cloud-common\maozi-cloud-common-generate-code\src\main\java\com\maozi\generate\code\GenerateCodeRun.java 执行

请输入模块名字(users):users
请输入生成地址(D:\project\maozi-cloud-parent\maozi-cloud-common):D:\project\maozi-cloud-parent\maozi-cloud-common
请输入是否依赖数据库(yes/no):yes
请输入数据库地址如 (默认 localhost:3306):
请输入数据库用户名(默认 root):
请输入数据库密码(默认 password):
请输入数据库名(默认 maozi-cloud-users-localhost-db):maozi-cloud-users-localhost-db
请输入子模块名(输入break结束):user
请输入表名(输入break结束):sys_user
请输入表名实体映射过滤前缀:sys
请输入表名(输入break结束):break
请输入子模块名(输入break结束):break
正在生成中   。。。。。。
代码生成完成   。。。。。



创建Nacos配置文件

文件名为:{项目名字}.yml

如:maozi-cloud-user.yml

#端口
application-port: 2000

# 设置数据库参数 以下值都是默认值 , 无变化可注释掉
application-datasource-jdbc-url: localhost:3306
application-datasource-jdbc-username: root
application-datasource-jdbc-password: password
application-datasource-db-name: maozi-cloud-user-localhost-db

#白名单
application-project-whitelist: /user/pc/v1/login


Nacos地址默认为localhost:8081,若不是则添加环境变量NACOS_CONFIG_SERVER

或找到 maozi-cloud-service-sso/src/main/resources/bootstrap.properties 添加

spring.cloud.nacos.config.server-addr={Nacos地址}


设置Jvm VM参数

因为用的是JDK17 所以要设置以下VM参数

--add-opens java.base/java.math=ALL-UNNAMED  --add-opens java.base/java.lang=ALL-UNNAMED  --add-opens java.base/java.lang.reflect=ALL-UNNAMED


启动服务

启动成功 ,访问 localhost:{端口}/doc.html



新服务包说明

可看MarkDown文档,里面有说明包作用

Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

简介

【脚手架】基于 SpringCloud Alibaba Dubbo 二开封装 展开 收起
Java
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/crmone/maozi-cloud-parent.git
git@gitee.com:crmone/maozi-cloud-parent.git
crmone
maozi-cloud-parent
maozi-cloud-parent
release

搜索帮助

53164aa7 5694891 3bd8fe86 5694891