Convert Figma logo to code with AI

zhoutaoo logoSpringCloud

Opensabre是基于SpringCloud2023的微服务开发平台,整合了Spring Security、Springcloud Alibaba等组件。 包含了基础的RBAC权限管理、授权认证、网关管理、服务治理、审计日志等系统管理基础应用。 定义了相关开发规范、风格并落地在服务框架层,开箱即用,支持Docker、Kubenetes的部署。 让项目开发人员快速进入业务开发,而不需过多时间花费在基础架构搭建和编码风格规范上。 目标是建立一套金融级、高安全性的微服务解决方案。

8,745
3,876
8,745
1

Top Related Projects

Spring Cloud Alibaba provides a one-stop solution for application development for the distributed solutions of Alibaba middleware.

Integration with Netflix OSS components

78,874

mall项目是一套电商系统,包括前台商城系统及后台管理系统,基于SpringBoot+MyBatis实现,采用Docker容器化部署。 前台商城系统包含首页门户、商品推荐、商品搜索、商品展示、购物车、订单流程、会员中心、客户服务、帮助中心等模块。 后台管理系统包含商品管理、订单管理、会员管理、促销管理、运营管理、内容管理、统计报表、财务管理、权限管理、设置等模块。

一个涵盖六个专栏:Spring Boot 2.X、Spring Cloud、Spring Cloud Alibaba、Dubbo、分布式消息队列、分布式事务的仓库。希望胖友小手一抖,右上角来个 Star,感恩 1024

《史上最简单的Spring Cloud教程源码》

Quick Overview

SpringCloud is a comprehensive microservices architecture project based on Spring Cloud. It provides a complete set of microservices solutions, including service discovery, configuration management, API gateway, circuit breaker, and more. The project aims to demonstrate best practices for building and deploying microservices using Spring Cloud.

Pros

  • Offers a complete microservices ecosystem with various components integrated
  • Provides detailed documentation and examples for each module
  • Implements security features, including OAuth2 authentication and authorization
  • Includes monitoring and logging solutions for better observability

Cons

  • Some parts of the documentation are in Chinese, which may be challenging for non-Chinese speakers
  • The project is quite complex, which might be overwhelming for beginners
  • Some dependencies may be outdated and require updates
  • Limited community support compared to more popular Spring Cloud examples

Code Examples

  1. Service Registration with Eureka
@SpringBootApplication
@EnableEurekaClient
public class ServiceApplication {
    public static void main(String[] args) {
        SpringApplication.run(ServiceApplication.class, args);
    }
}

This code snippet shows how to enable Eureka client for service registration.

  1. API Gateway Configuration
spring:
  cloud:
    gateway:
      routes:
        - id: user-service
          uri: lb://USER-SERVICE
          predicates:
            - Path=/user/**

This YAML configuration demonstrates how to set up a route in the API Gateway.

  1. Circuit Breaker with Hystrix
@HystrixCommand(fallbackMethod = "fallbackMethod")
public String callService() {
    // Service call logic
}

public String fallbackMethod() {
    return "Fallback response";
}

This example shows how to use Hystrix for implementing a circuit breaker pattern.

Getting Started

  1. Clone the repository:

    git clone https://github.com/zhoutaoo/SpringCloud.git
    
  2. Navigate to the project directory:

    cd SpringCloud
    
  3. Build the project using Maven:

    mvn clean install
    
  4. Start the required services (e.g., Eureka, Config Server, Gateway):

    java -jar auth/authentication-server/target/authentication-server.jar
    java -jar gateway/gateway-web/target/gateway-web.jar
    java -jar center/eureka/target/eureka-server.jar
    
  5. Access the Eureka dashboard at http://localhost:8761 to verify service registration.

Competitor Comparisons

Spring Cloud Alibaba provides a one-stop solution for application development for the distributed solutions of Alibaba middleware.

Pros of spring-cloud-alibaba

  • Extensive integration with Alibaba Cloud services
  • Larger community and more frequent updates
  • Comprehensive documentation and examples

Cons of spring-cloud-alibaba

  • Steeper learning curve due to more complex features
  • Potential vendor lock-in with Alibaba Cloud services

Code Comparison

SpringCloud:

@SpringBootApplication
@EnableDiscoveryClient
public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}

spring-cloud-alibaba:

@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}

Key Differences

  • spring-cloud-alibaba offers more advanced features like Sentinel for circuit breaking and flow control
  • SpringCloud focuses on a simpler, more straightforward implementation of microservices
  • spring-cloud-alibaba provides better support for distributed configuration management with Nacos

Use Cases

  • SpringCloud: Ideal for smaller projects or teams new to microservices architecture
  • spring-cloud-alibaba: Better suited for large-scale applications, especially those leveraging Alibaba Cloud services

Community and Support

  • spring-cloud-alibaba has a larger user base and more active development
  • SpringCloud offers a simpler codebase, making it easier for contributors to understand and modify

Integration with Netflix OSS components

Pros of Spring Cloud Netflix

  • Official Spring Cloud project with extensive documentation and community support
  • Comprehensive set of tools for building microservices, including service discovery, load balancing, and circuit breakers
  • Seamless integration with other Spring Cloud components

Cons of Spring Cloud Netflix

  • Larger footprint and potentially higher resource consumption
  • More complex configuration and setup process
  • Some components (e.g., Hystrix) are in maintenance mode

Code Comparison

SpringCloud:

@SpringBootApplication
@EnableDiscoveryClient
public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}

Spring Cloud Netflix:

@SpringBootApplication
@EnableEurekaClient
public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}

The main difference in the code is the use of @EnableDiscoveryClient in SpringCloud versus @EnableEurekaClient in Spring Cloud Netflix. SpringCloud uses a more generic annotation, while Spring Cloud Netflix specifically enables Eureka for service discovery.

Both projects aim to simplify microservices development, but Spring Cloud Netflix offers a more comprehensive and widely adopted solution, while SpringCloud provides a lighter alternative with potentially easier setup and configuration.

78,874

mall项目是一套电商系统,包括前台商城系统及后台管理系统,基于SpringBoot+MyBatis实现,采用Docker容器化部署。 前台商城系统包含首页门户、商品推荐、商品搜索、商品展示、购物车、订单流程、会员中心、客户服务、帮助中心等模块。 后台管理系统包含商品管理、订单管理、会员管理、促销管理、运营管理、内容管理、统计报表、财务管理、权限管理、设置等模块。

Pros of mall

  • More comprehensive e-commerce functionality, including product management, order processing, and user systems
  • Extensive documentation and deployment guides, making it easier for developers to understand and implement
  • Active community with frequent updates and contributions

Cons of mall

  • Larger codebase and more complex architecture, potentially harder to grasp for beginners
  • Focused specifically on e-commerce, less flexible for other types of applications
  • Heavier resource requirements due to its comprehensive nature

Code Comparison

mall:

@ApiOperation("添加商品")
@RequestMapping(value = "/create", method = RequestMethod.POST)
@ResponseBody
public CommonResult create(@RequestBody PmsProductParam productParam) {
    int count = productService.create(productParam);
    if (count > 0) {
        return CommonResult.success(count);
    } else {
        return CommonResult.failed();
    }
}

SpringCloud:

@PostMapping("/product")
public ResponseEntity<Product> createProduct(@RequestBody Product product) {
    Product savedProduct = productService.save(product);
    return ResponseEntity.ok(savedProduct);
}

The mall project provides more detailed API documentation and uses a custom result object, while SpringCloud uses standard Spring ResponseEntity. Mall's code is more tailored for e-commerce, whereas SpringCloud's is more generic.

一个涵盖六个专栏:Spring Boot 2.X、Spring Cloud、Spring Cloud Alibaba、Dubbo、分布式消息队列、分布式事务的仓库。希望胖友小手一抖,右上角来个 Star,感恩 1024

Pros of SpringBoot-Labs

  • More comprehensive coverage of Spring Boot topics and features
  • Regularly updated with new examples and technologies
  • Better organized structure with separate modules for different concepts

Cons of SpringBoot-Labs

  • Lacks focus on microservices architecture compared to SpringCloud
  • May be overwhelming for beginners due to the large number of examples
  • Less emphasis on production-ready configurations

Code Comparison

SpringBoot-Labs:

@SpringBootApplication
public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}

SpringCloud:

@SpringCloudApplication
@EnableFeignClients
public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}

The main difference in the code snippets is the use of @SpringCloudApplication and @EnableFeignClients annotations in SpringCloud, which are specific to microservices architecture and inter-service communication. SpringBoot-Labs uses the standard @SpringBootApplication annotation, focusing on general Spring Boot applications.

SpringBoot-Labs provides a wider range of examples and topics related to Spring Boot, making it suitable for learning various aspects of the framework. On the other hand, SpringCloud is more focused on building microservices-based applications using Spring Cloud components.

《史上最简单的Spring Cloud教程源码》

Pros of SpringCloudLearning

  • More beginner-friendly with step-by-step tutorials and explanations
  • Covers a wider range of Spring Cloud components and features
  • Regularly updated with newer Spring Cloud versions

Cons of SpringCloudLearning

  • Less comprehensive in terms of a complete microservices architecture
  • Lacks advanced security implementations and configurations
  • Doesn't include as many real-world scenarios or production-ready examples

Code Comparison

SpringCloudLearning:

@SpringBootApplication
@EnableEurekaServer
public class EurekaServerApplication {
    public static void main(String[] args) {
        SpringApplication.run(EurekaServerApplication.class, args);
    }
}

SpringCloud:

@SpringBootApplication
@EnableEurekaServer
@EnableResourceServer
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class EurekaServerApplication {
    public static void main(String[] args) {
        SpringApplication.run(EurekaServerApplication.class, args);
    }
}

The SpringCloud example includes additional security-related annotations, demonstrating a more production-ready approach to service discovery implementation.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Build Status License

前言

根据前期的使用和反馈,目前将脚手架整体进行了重构,发布了新的框架 Opensabre,请使用新版。

💪Opensabre是基于SpringCloud2023的微服务开发平台,整合了Spring Security、Springcloud Alibaba等组件。

包含了基础的RBAC权限管理、授权认证、网关管理、服务治理、审计日志等系统管理基础应用。

定义了相关开发规范、风格并落地在服务框架层,开箱即用,支持Docker、Kubenetes的部署。

让项目开发人员快速进入业务开发,而不需过多时间花费在基础架构搭建和编码风格规范上。

目标是建立一套金融级、高安全性的微服务解决方案。

项目介绍

框架源码: https://github.com/opensabre/opensabre-framework

在线文档: https://opensabre.github.io/docs

功能特点

1. 统一Restful的响应报文,controll返回原始类型即可,无需手动包装,简化代码,可读性更好。

2. 统一异常处理,封装了基本的异常的响应,如参数检验、文件上传等。简化代码,更方便扩展。

3. 默认集成knife4j和Swagger 3.0 API文档,方便接口文档的传递、协作与调试。

4. 标准化WEB对象传递/转换/使用,方便统一开发风格,简化操作。

5. 框架/环境等元数据自动收集注册至properties和Nacos,方便系统运行时作为扩展判断,信息处理。

6. 系统启动时自动收集所有Restful url注册到权限资源,方便进行集中权限管理和授权使用。

7. 多机房/双活路由负载扩展支持,自定义路由和负载规则,更灵活、可控。

8. 默认引入spring validation,并扩展枚举、手机号等常用校验注解。

9. 默认引入日志trace、actuator等组件,统一日志打印格式。

10. 整体系统化为三层,framework框架、framework组件、基础应用,层次更清楚,结构更合理。

11. 配置中心,划分框架全局配置与应用配置(熔断降级、网关路由),配置项支持加密处理。

12. 支持日志敏感数据脱敏配置,响应报文敏感数据注解胶敏。

快速开始

先决条件

首先本机先要安装以下环境,建议先学习了解springboot和springcloud基础知识。

依赖说明: https://opensabre.github.io/docs/#/framework/introduction/dependencies

工程介绍:https://opensabre.github.io/docs/#/framework/introduction/PROJECT

快速入门

本工程是一个聚合工程,相关模块引用了 https://github.com/opensabre 的相关模块

  1. 学习源码请克隆代码库: git clone https://github.com/zhoutaoo/SpringCloud.git --recursive

  2. 快速使用框架开发请参考:https://opensabre.github.io/docs/#/framework/manual/QUICKSTART

基础应用使用

基础应用脚本

  • 1.创建数据库及表

路径一般为:应用/src/main/resources/db

如:base-origanization/src/main/resources/db 下的脚本,请先执行db文件创建库,再执行ddl建立表结构后再执行dml数据初使化

  • 2.启动应用

根据自己需要,启动相应服务进行测试,cd 进入相关应用目录,执行命令: mvn spring-boot:run 或者通过ide提供的运行功能。

  • 3.测试验证

可通过命令行或postman类的工具进行请求,应用端口默认8080

root@xxxxx # curl http://localhost:8080/test/echo?name=zhangsan

{   
    "code":"000000",
    "mesg":"处理成功",
    "time":"2022-11-22T14:46:58.643Z",
    "data":"Hello:zhangsan"
}

默认文档地址如下:

swagger文档地址:http://localhost:8080/swagger-ui/index.html

knife4j文档地址:http://localhost:8080/doc.html

架构与开发

系统架构

功能与特性

功能预览

用户管理 用户管理

角色管理 角色管理

服务容错 服务容错

API文档 API文档

组织架构管理 组织架构管理

基础服务

服务使用技术进度备注
注册中心Nacos✅
配置中心Nacos✅
消息总线SpringCloud Bus+Rabbitmq✅
动态网关SpringCloud Gateway✅多种维度的流量控制(服务、IP、用户等),后端可配置化🏗
授权认证Spring Security OAuth2✅Jwt模式
服务容错SpringCloud Sentinel✅
服务调用SpringCloud OpenFeign✅
对象存储Minio🏗
数据权限🏗使用mybatis对原查询做增强,业务代码不用控制,即可实现。

更新日志

版本说明

联系交流

加入贡献代码

请入群 请戳这里 加群主微信。

请作者喝饮料

如果你觉的有帮助到您,可以请作者喝饮料,这样更有动力,谢谢。

zfb wx

学习交流

Email:zhoutaoo@foxmail.com

**问问题的三要素**

  1. 说明背景,使用了哪个模块,要做什么?

  2. 怎么输入或操作的得到了什么结果? 截图,日志

  3. 哪里不明白或有什么疑问 ?

Stargazers over time

Stargazers over time