Token导航 LogoToken导航TokenDH.com
研究检索需要联网github未标认证来源可访问许可证需确认审计通过

spring-cloud-basics春季云基础知识

Agent Skill

用于辅助 Java 项目开发、面向对象设计、Spring 生态、Maven 或 Gradle 依赖和后端工程实践。它适合让 Agent 分析类结构、设计接口、整理服务分层、生成测试或检查常见代码坏味道。使用时需要结合项目已有架构、包结构和依赖版本,不应只按通用教程改代码;涉及数据库、事务、并发或框架配置时,应先确认运行环境和回归测试范围。

总安装

588

周安装

25

GitHub Stars

12

下载量

206
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:spring-cloud-basics(春季云基础知识)
来源仓库:https://github.com/claude-dev-suite/claude-dev-suite
仓库路径:skills/spring-cloud-basics
安装命令:
npx skills add https://github.com/claude-dev-suite/claude-dev-suite --skill spring-cloud-basics
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/claude-dev-suite/claude-dev-suite --skill spring-cloud-basics

简介

Spring Cloud 微服务基础概念与实践入门指南。

  • 适用于理解服务拆分、API 网关与配置中心的核心原理。
  • 提供 Feign、Ribbon 与 Hystrix 的经典用法示例代码。
  • 经典组件已逐步被 Spring Cloud Gateway 与 Resilience4j 替代。
  • 学习时应对照官方文档验证示例在新版本中的有效性。

SKILL.md

Spring Cloud Basics

Architecture Overview

┌─────────────────────────────────────────────────────────────────┐
│                        API Gateway                               │
│                    (Spring Cloud Gateway)                        │
└───────────────────────────┬─────────────────────────────────────┘
                            │
┌───────────────────────────▼─────────────────────────────────────┐
│                     Service Discovery                            │
│                    (Eureka / Consul)                             │
└──────────┬─────────────────┬─────────────────┬──────────────────┘
           │                 │                 │
    ┌──────▼──────┐   ┌──────▼──────┐   ┌──────▼──────┐
    │  Service A  │   │  Service B  │   │  Service C  │
    │  (3 inst.)  │   │  (2 inst.)  │   │  (1 inst.)  │
    └─────────────┘   └─────────────┘   └─────────────┘
           │                 │                 │
           └─────────────────┼─────────────────┘
                             ▼
                    ┌────────────────┐
                    │  Config Server │
                    └────────────────┘

Quick Start - Eureka

Server

@SpringBootApplication
@EnableEurekaServer
public class EurekaServerApplication {
    public static void main(String[] args) {
        SpringApplication.run(EurekaServerApplication.class, args);
    }
}
server:
  port: 8761
eureka:
  client:
    register-with-eureka: false
    fetch-registry: false

Client

spring:
  application:
    name: product-service
eureka:
  client:
    service-url:
      defaultZone: http://localhost:8761/eureka
  instance:
    prefer-ip-address: true
Full Reference: See service-discovery.md for Eureka HA and Config Server.

Quick Start - API Gateway

spring:
  cloud:
    gateway:
      routes:
        - id: product-service
          uri: lb://product-service
          predicates:
            - Path=/api/products/**
          filters:
            - StripPrefix=0
Full Reference: See gateway.md for custom filters and programmatic routes.

Quick Start - Circuit Breaker

@Service
public class ProductClient {

    @CircuitBreaker(name = "productService", fallbackMethod = "fallback")
    @Retry(name = "productService")
    public List<Product> getProducts() {
        return restClient.get()
            .uri("http://product-service/api/products")
            .retrieve()
            .body(new ParameterizedTypeReference<>() {});
    }

    private List<Product> fallback(Exception e) {
        return List.of();
    }
}
resilience4j:
  circuitbreaker:
    instances:
      productService:
        sliding-window-size: 10
        failure-rate-threshold: 50
        wait-duration-in-open-state: 10s
Full Reference: See resilience.md for Retry, Bulkhead, Rate Limiter, Feign.

Service Communication Pattern

@Service
@RequiredArgsConstructor
public class OrderService {

    private final ProductClient productClient;
    private final InventoryClient inventoryClient;
    private final PaymentClient paymentClient;

    @Transactional
    public Order createOrder(CreateOrderRequest request) {
        // 1. Verifica prodotti
        List<Product> products = request.items().stream()
            .map(item -> productClient.getProductById(item.productId()))
            .toList();

        // 2. Verifica inventario
        boolean available = inventoryClient.checkAvailability(request.items());
        if (!available) {
            throw new InsufficientInventoryException("Items not available");
        }

        // 3. Crea ordine
        Order order = Order.create(request.customerId(), products, request.items());
        order = orderRepository.save(order);

        // 4. Riserva inventario
        inventoryClient.reserveItems(order.getId(), request.items());

        // 5. Processa pagamento (con rollback)
        try {
            PaymentResult payment = paymentClient.processPayment(
                new PaymentRequest(order.getId(), order.getTotal())
            );
            order.setPaymentId(payment.paymentId());
            order.setStatus(OrderStatus.PAID);
        } catch (PaymentFailedException e) {
            inventoryClient.releaseReservation(order.getId());
            order.setStatus(OrderStatus.PAYMENT_FAILED);
            throw e;
        }

        return orderRepository.save(order);
    }
}

Load Balancer

@Configuration
public class LoadBalancerConfig {

    @Bean
    @LoadBalanced
    public RestClient.Builder loadBalancedRestClientBuilder() {
        return RestClient.builder();
    }
}

// Usage: use service name instead of host
restClient.get()
    .uri("http://product-service/api/products")
    .retrieve()
    .body(new ParameterizedTypeReference<>() {});

Distributed Tracing

management:
  tracing:
    sampling:
      probability: 1.0
  zipkin:
    tracing:
      endpoint: http://localhost:9411/api/v2/spans

logging:
  pattern:
    level: "%5p [${spring.application.name:},%X{traceId:-},%X{spanId:-}]"

Best Practices

DoDon't
Use Service Discovery for all servicesHardcode service URLs
Implement Circuit Breaker with fallbackIgnore failures
Centralize config with Config ServerDuplicate configuration
Add distributed tracingMiss observability
Use API Gateway as single entry pointExpose services directly

When NOT to Use This Skill

  • Single service - Spring Cloud adds unnecessary complexity
  • Kubernetes native - Use K8s service discovery, ConfigMaps
  • Simple deployments - Overhead not justified
  • Specific components - Use dedicated skills for deep dives

Common Pitfalls

ErrorCauseSolution
No instances availableService not registeredVerify Eureka registration
Connection refusedService downImplement Circuit Breaker
TimeoutService slowConfigure appropriate timeouts
Config not loadingConfig server unreachableUse fail-fast: false or fallback
Load balancing not workingMissing @LoadBalancedAnnotate RestClient builder

Anti-Patterns

Anti-PatternProblemSolution
Hardcoding service URLsNo discovery benefitUse service names
No circuit breakerCascading failuresAdd Resilience4j
Missing retryTransient failuresConfigure retry with backoff
No config refreshChanges need redeployUse @RefreshScope
Synchronous everywhereTight couplingUse async where appropriate

Quick Troubleshooting

ProblemDiagnosticFix
Service not foundCheck Eureka dashboardVerify registration
Config not loadingCheck config server logsVerify path, profile
Circuit always openCheck failure thresholdTune thresholds
Gateway routing failsCheck predicatesVerify route config
Load balancing not workingCheck @LoadBalancedAdd annotation

Reference Files

FileContent
service-discovery.mdEureka Server/Client, Config Server
gateway.mdAPI Gateway, Filters, Routes
resilience.mdCircuit Breaker, Retry, Feign, Testing

External Documentation

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

36.14%
按下载量换算74

Claude

29.41%
按下载量换算61

Cursor

16.76%
按下载量换算35

Gemini CLI

9.07%
按下载量换算19

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills