SpringCloud
Opensabre是基于SpringCloud2023的微服务开发平台,整合了Spring Security、Springcloud Alibaba等组件。 包含了基础的RBAC权限管理、授权认证、网关管理、服务治理、审计日志等系统管理基础应用。 定义了相关开发规范、风格并落地在服务框架层,开箱即用,支持Docker、Kubenetes的部署。 让项目开发人员快速进入业务开发,而不需过多时间花费在基础架构搭建和编码风格规范上。 目标是建立一套金融级、高安全性的微服务解决方案。
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
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
- 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.
- 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.
- 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
-
Clone the repository:
git clone https://github.com/zhoutaoo/SpringCloud.git
-
Navigate to the project directory:
cd SpringCloud
-
Build the project using Maven:
mvn clean install
-
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
-
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.
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
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
åè¨
æ ¹æ®åæç使ç¨ååé¦ï¼ç®åå°èææ¶æ´ä½è¿è¡äºéæï¼åå¸äºæ°çæ¡æ¶ 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
çç¸å
³æ¨¡å
-
å¦ä¹ æºç 请å é代ç åºï¼
git clone https://github.com/zhoutaoo/SpringCloud.git --recursive
-
å¿«é使ç¨æ¡æ¶å¼å请åèï¼
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ææ¡£
ç»ç»æ¶æ管ç
åºç¡æå¡
æå¡ | 使ç¨ææ¯ | è¿åº¦ | å¤æ³¨ |
---|---|---|---|
注åä¸å¿ | Nacos | â | |
é ç½®ä¸å¿ | Nacos | â | |
æ¶æ¯æ»çº¿ | SpringCloud Bus+Rabbitmq | â | |
å¨æç½å ³ | SpringCloud Gateway | â | å¤ç§ç»´åº¦çæµéæ§å¶ï¼æå¡ãIPãç¨æ·çï¼ï¼å端å¯é ç½®åð |
ææè®¤è¯ | Spring Security OAuth2 | â | Jwtæ¨¡å¼ |
æå¡å®¹é | SpringCloud Sentinel | â | |
æå¡è°ç¨ | SpringCloud OpenFeign | â | |
对象åå¨ | Minio | ð | |
æ°æ®æé | ð | 使ç¨mybatis对åæ¥è¯¢åå¢å¼ºï¼ä¸å¡ä»£ç ä¸ç¨æ§å¶ï¼å³å¯å®ç°ã |
æ´æ°æ¥å¿
è系交æµ
å å ¥è´¡ç®ä»£ç
è¯·å ¥ç¾¤ 请æ³è¿é å 群主微信ã
请ä½è å饮æ
å¦æä½ è§çæ帮å©å°æ¨ï¼å¯ä»¥è¯·ä½è å饮æï¼è¿æ ·æ´æå¨åï¼è°¢è°¢ã
å¦ä¹ 交æµ
Emailï¼zhoutaoo@foxmail.com
**é®é®é¢çä¸è¦ç´ **
-
说æèæ¯ï¼ä½¿ç¨äºåªä¸ªæ¨¡åï¼è¦åä»ä¹ï¼
-
æä¹è¾å ¥ææä½çå¾å°äºä»ä¹ç»æï¼ æªå¾ï¼æ¥å¿
-
åªéä¸æç½ææä»ä¹çé® ï¼
Stargazers over time
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
mall项目是一套电商系统,包括前台商城系统及后台管理系统,基于SpringBoot+MyBatis实现,采用Docker容器化部署。 前台商城系统包含首页门户、商品推荐、商品搜索、商品展示、购物车、订单流程、会员中心、客户服务、帮助中心等模块。 后台管理系统包含商品管理、订单管理、会员管理、促销管理、运营管理、内容管理、统计报表、财务管理、权限管理、设置等模块。
一个涵盖六个专栏:Spring Boot 2.X、Spring Cloud、Spring Cloud Alibaba、Dubbo、分布式消息队列、分布式事务的仓库。希望胖友小手一抖,右上角来个 Star,感恩 1024
《史上最简单的Spring Cloud教程源码》
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot