# cloud-demo **Repository Path**: junjun_com/cloud-demo ## Basic Information - **Project Name**: cloud-demo - **Description**: 快速通关SpringCloud,内容涵盖:分布式基础概念、Nacos注册中心与配置中心、OpenFeign远程调用、Sentinel流量保护、Gateway网关、Seata分布式事务等。 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2025-06-26 - **Last Updated**: 2026-01-05 ## Categories & Tags **Categories**: Uncategorized **Tags**: SpringBoot, SpringCloud ## README # Gitee Project README ## Project Introduction This project is a distributed system based on a microservices architecture, primarily designed to demonstrate interactions between order, product, account, and inventory services. The system uses Spring Boot, Spring Cloud, and Seata to handle distributed transactions. It also integrates Nacos as a service registry and configuration center, Feign for inter-service communication, and Sentinel for traffic control and circuit breaking. This project is suitable for developers who want to learn or demonstrate microservices architecture and its related technology stack. ## Technology Stack - Spring Boot - Spring Cloud - Seata (Distributed Transactions) - Nacos (Service Discovery & Configuration Management) - Feign (Service Communication) - Sentinel (Traffic Control & Circuit Breaking) - MyBatis (Data Access) - Redis (Caching) ## Main Modules - **gateway**: Provides a microservice gateway with custom filters and routing rules. - **model**: Contains common classes (such as the `R` generic response class) and business models (such as `Order`, `Product`). - **services/seata-account**: Handles account balance-related business logic. - **services/seata-business**: Business logic for the purchase process, using Seata to implement distributed transactions. - **services/seata-order**: Handles order creation logic, integrated with Sentinel and Feign. - **services/seata-storage**: Handles inventory deduction logic. - **services/service-order**: Order service, integrated with Feign, Sentinel, and Redis. - **services/service-product**: Product service, providing product information retrieval. ## Installation and Startup ### Prerequisites - Java 1.8 or higher - Maven - Nacos Server - Seata Server - Redis Server (optional) ### Startup Steps 1. **Start Nacos Server** Ensure that Nacos is running and create the necessary configurations. 2. **Start Seata Server** Configure file.conf and registry.conf, then start the Seata service. 3. **Start Each Microservice Module** - `services/seata-account`: Start the account service - `services/seata-order`: Start the order service - `services/seata-storage`: Start the inventory service - `services/seata-business`: Start the purchase business service - `services/service-product`: Start the product service - `gateway`: Start the gateway service 4. **Access Services** - Access REST interfaces of each service through the gateway. ## Usage Examples - **Create an Order** Send a GET request to: `http://localhost:8080/purchase?userId=xxx&commodityCode=xxx&count=xxx` This request will trigger a distributed transaction, deducting inventory, placing an order, and deducting funds. - **View Order Information** Send a GET request to: `http://localhost:8080/order/create?userId=xxx&productId=xxx` - **Test Rate Limiting and Degradation** Use Sentinel to configure rate-limiting policies for the `/seckill` endpoint and test the degradation logic. ## Contribution Guide Pull Requests are welcome to improve the project. Please ensure: - Code style matches the existing codebase - New features include corresponding tests - Run tests and ensure they pass before submission ## License This project is licensed under the MIT License. For details, please refer to the LICENSE file. ## Contact For feedback or suggestions, please submit an Issue or contact the project maintainers.