6 Star 15 Fork 16

steellee / SAO

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

SAO项目介绍

基于Spring Cloud(Finchley版本)架构体系,整合各微服务基础组件的最新最全的脚手架工程。

一,SAO背景目的

本项目是基于开发银行二类户开户平台,业务逻辑已经剥离,只剩下骨架及服务基础组件,只需稍加改造,就可以作为开发新项目的脚手架工程。
本脚手架目的:为减少重复架构,统一基础服务,让开发人员把重心放在各微服务的业务逻辑的开发上来。

二,SAO功能技术点

技术 名称 官网
Spring Cloud 分布式微服务框架 https://projects.spring.io/spring-cloud/
Spring Boot 快速应用开发Spring框架 https://spring.io/projects/spring-boot/
Ratelimit 网关限流框架 https://github.com/marcosbarbero/spring-cloud-zuul-ratelimit/
OAuth2 Oauth2认证服务 https://spring.io/projects/spring-security-oauth/
Spring session 分布式Session管理 http://projects.spring.io/spring-session/
MyBatis ORM框架 http://www.mybatis.org/mybatis-3/zh/index.html/
MyBatis Generator 代码生成 http://www.mybatis.org/generator/index.html/
PageHelper MyBatis物理分页插件 http://git.oschina.net/free/Mybatis_PageHelper
Druid 数据库连接池 https://github.com/alibaba/druid/
Sharding-JDBC 分布式数据库中间件 http://shardingsphere.io/
Fastdfs 轻量级分布式文件系统 https://github.com/happyfish100/fastdfs/
Redis 分布式缓存数据库 https://redis.io/
Swagger2 接口测试框架 http://swagger.io/
Maven 项目构建管理 http://maven.apache.org/
Spring Boot Admin 分布式微服务监控中心 https://github.com/codecentric/spring-boot-admin/
Hystrix-dashboard Hystrix的仪表盘组件 https://github.com/spring-cloud-samples/hystrix-dashboard/
Turbine Hystrix熔断聚合组件 https://github.com/spring-cloud-samples/turbine/
Zipkin 分布式链路跟踪系统 https://zipkin.io/
Kafka/RabbitMQ 消息中间件 http://kafka.apache.org https://www.rabbitmq.com/
easypoi Excel快速POI工具类 https://gitee.com/lemur/easypoi/

三,SAO脚手架模块说明

================================================

  • sao-gateway:平台网关
  • sao-eureka:平台服务注册与发现服务中心
  • sao-config:平台配置中心
  • sao-manager:
    • sao-sba:平台日志管理,硬件,微服务监控状态监控
    • sao-turbine:平台熔断监控
  • sao-modules
    • sao-common:工具类,共通配置,常用数据类型存放(例如VO模型对象定义,常量,枚举等)
    • cmbc-service:demo用微服务
    • demoa-service:demo用微服务
    • demob-service:demo用微服务
    • mq-service:消息中心
    • auth-service:接口认证中心

================================================

(一)平台网关(sao-gateway)

已整合灰度发布(蓝绿/金丝雀发布)、Ribbon均衡负载(自定义)请求限流、熔断降级、 Swagger API文档,动态加载的过滤器等功能:

1, 网关限流框架 spring-cloud-zuul-ratelimit(BUCKET4J)

对应服务:http://localhost:8101

(二)平台服务注册与发现服务中心(sao-eureka)

已支持单点/集群(178/179);
1,单点:http://localhost:8201/eureka/
2,集群node1启动: java -jar sao-eureka-1.0.0-SNAPSHOT.jar --spring.profiles.active=node1 
   对应服务:http://10.7.111.178:8201/eureka/
3,集群node2启动: java -jar sao-eureka-1.0.0-SNAPSHOT.jar --spring.profiles.active=node2
   对应服务:http://10.7.111.179:8201/eureka/

(三)平台配置中心(sao-config)

已支持Git/DB;
1, Git配置:application-git.yml
2, DB配置存储:对应schema:sao_master,表:sys_config_properties

对应服务:http://localhost:8301

(四)业务微服务Demo(cmbc-service)

1.0 支持功能点:

1.1 Spring Boot 2.x + Mybatis + PageHelper + Druid + Mysql
1.2 支持Swagger2构建RESTful API
1.3 Sharding-JDBC 3.x 主从分离(一主一从)
    * 对应主从配置:application-shardingjdbc-masterslave.properties
    * 对应主从:sao_master(主),sao_slave(从)
    * 注意: sql在cmbc-service的resource下;另如需主从复制,需要服务器自行配置:见下
1.4 Spring-Session + Redis: SSO单点登录,分布式Session管理
1.5 Redis Sentinel模式集群
    * 对应配置:application-redis.properties
    * 对应集群节点:10.7.111.179:6379,10.7.111.178:6380,10.7.111.178:6381
    * 对应哨兵节点:10.7.111.179:26379,10.7.111.178:26479,10.7.111.178:26579DB
    * 注意: 集群服务器环境需要自行配置:见下
1.6 Fastdfs轻量级分布式文件系统
    * 对应配置:fastdfs-client.properties,fdfs_client.conf
    * 注意: 服务器环境需要自行配置:见下

2.0 启动准备

2.1 已配置DB主从, 先建库和表,见sao_master.sql及sao_slave.sql
2.2 已配置redis集群节点, 先启动服务器的集群及哨兵节点
2.3 已配置bootstrap.yml, 先启动配置中心:sao-config

对应服务:http://localhost:8501/swagger-ui.html

(五)消息中心Demo(mq-service)

已支持RabbitMQ /Kafka /RocketMQ, 具体详细说明: 参照链接

(六)接口认证中心Demo(auth-service)

已支持Oauth2 客户端方式认证, 具体详细说明: 参照链接

(七) 工具类共通配置中心Demo(sao-common)

  • 已支持功能列表:
    • 各种微服务所需配置(cache, db, spring-session)
    • Fastdfs/Ftp/Sftp自建文件服务器的上传,下载
    • Easypoi支持Excel的快速导入导出,Excel模板导出,Word模板导出
    • Http/Https client工具
    • AES对称,RSA非对称加解密,Hex十六进制/数组互转,Base64编码等安全工具
    • 身份证,基本类型等校验工具
    • UUID,22/24位纳秒时间ID,SnowFlake分布式ID等生成工具
    • ...各种基本工具

(八)管理监控(sao-manager)

A, sao-sba综合管理监控:

应用场景:
sba为spring boot应用提供了整合简洁的可视化 WEB UI,应用的详情视图提供了应用本身及运行时环境(OS和JVM)
还包括各微服务应用的运行时信息,显示在线状态邮件提醒,日志级别管理,线程管理,Environment管理, 
Http跟踪, Audit日志等运维数据。在Journal模块,可以提供整个集群所有节点的状态变化历程。
操作说明:

1.0 启动微服务

1.1 启动demoa-service微服务:        http://localhost:8502/helloA?name=sao
1.2 启动demob-service微服务:        http://localhost:8503/helloB?name=sao

2.0 启动综合管理控台

2.1 启动sao-sba服务: http://localhost:8411
2.2 登录用户名和密码:admin/admin
2.2 登录后,在控台中将看到上面启动的两个微服务各维度的监控情况

3.0 控台相关画面展示

图片名称 图片名称 图片名称

B, sao-turbine断路器聚合监控:

应用场景:
为保证微服务的可用性,防止微服务出错导致网络阻塞,出现了断路器模型。
有很多个微服务的时候,这就需要用Turbine聚合所有服务的Hystrix Dashboard
操作说明:

1.0 开启注册与发现服务

启动sao-eureka服务: http://localhost:8201/eureka/

2.0 启动熔断微服务

2.1 启动demoa-service微服务:        http://localhost:8502/helloA?name=sao
2.2 启动demob-service微服务:        http://localhost:8503/helloB?name=sao

3.0 启动Turbine,Hystrix Dashboard

3.1 访问turbine.stream网页,能得到返回数据:http://localhost:8401/turbine.stream
3.2 访问Hystrix Dashboard网页:http://localhost:8401/hystrix
3.3 Dashboard网页中,输入http://localhost:8401/turbine.stream回车
3.4 Dashboard网页中,会出现多个聚合熔断服务

4.0 控台相关画面展示

图片名称 图片名称

C, Zipkin服务追踪调用链:

应用场景:
在分布式系统中提供追踪服务调用解决方案

对外暴露的一个接口,可能需要很多个服务协同才能完成这个接口功能,
如果链路上任何一个服务出现问题或者网络超时,都会形成导致接口调用失败。
随着业务的不断扩张,服务之间互相调用会越来越复杂。
操作说明:

1.0 构建zipkin-server 在spring Cloud为F版本的时候,已经不需要自己构建Zipkin Server了,只需要下载jar即可.

1.1 下载地址:https://dl.bintray.com/openzipkin/maven/io/zipkin/java/zipkin-server/
1.2 需要运行: java -jar zipkin-server-2.10.4-exec.jar
1.3 访问浏览器localhost:9411

2.0 构建zipkin-client

2.1 各微服务只需添加以下依赖:
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-zipkin</artifactId>
    </dependency>
    
2.2 demo中,可启动demoa-service和demob-service两个微服务后,在zipkin server中追踪调用链
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: You must give any other recipients of the Work or Derivative Works a copy of this License; and You must cause any modified files to carry prominent notices stating that You changed the files; and 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 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 2018 steellee 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.

简介

基于Spring Cloud(Finchley版本)架构体系,整合各微服务基础组件的最新最全的脚手架工程。微服务架构: Spring Cloud全家桶 + Spring boot 2.x + OAuth2 + Mybatis + Druid + Mysql + Sharding-JDBC 3.x + Redis Sentinel + Spring-Session + Fastdfs ; 全方位监控:Spring Boot Admin 2.x + Turbine + Hystrix Dashboard + Zipkin 展开 收起
Java
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/steellee/sao.git
git@gitee.com:steellee/sao.git
steellee
sao
SAO
master

搜索帮助