
spring-cloud
Provides comprehensive guidance for Spring Cloud microservices including service discovery, configuration management, load balancing, circuit breakers, API gateways, and distributed tracing. Use when the user asks about Spring Cloud, needs to build microservices, implement service discovery, or work with Spring Cloud components.
- Installs
- 202
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/full-stack-skills/spring-skills --skill spring-cloud- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads spring-cloud automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
Spring Cloud 微服务开发指南
概述
Spring Cloud 是一套完整的微服务解决方案,提供了服务注册与发现、配置管理、网关、负载均衡、熔断器等组件。
核心组件
1. 服务注册与发现(Eureka)
Eureka Server:
@SpringBootApplication
@EnableEurekaServer
public class EurekaServerApplication {
public static void main(String[] args) {
SpringApplication.run(EurekaServerApplication.class, args);
}
}
application.yml:
server:
port: 8761
eureka:
instance:
hostname: localhost
client:
register-with-eureka: false
fetch-registry: false
service-url:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
Eureka Client:
@SpringBootApplication
@EnableEurekaClient
public class UserServiceApplication {
public static void main(String[] args) {
SpringApplication.run(UserServiceApplication.class, args);
}
}
application.yml:
spring:
application:
name: user-service
eureka:
client:
service-url:
defaultZone: http://localhost:8761/eureka/
2. 配置中心(Config Server)
Config Server:
@SpringBootApplication
@EnableConfigServer
public class ConfigServerApplication {
public static void main(String[] args) {
SpringApplication.run(ConfigServerApplication.class, args);
}
}
application.yml:
server:
port: 8888
spring:
cloud:
config:
server:
git:
uri: https://github.com/example/config-repo
search-paths: '{application}'
Config Client:
spring:
application:
name: user-service
cloud:
config:
uri: http://localhost:8888
name: user-service
profile: dev
3. API 网关(Gateway)
Gateway 配置:
@SpringBootApplication
public class GatewayApplication {
public static void main(String[] args) {
SpringApplication.run(GatewayApplication.class, args);
}
}
application.yml:
spring:
cloud:
gateway:
routes:
- id: user-service
uri: lb://user-service
predicates:
- Path=/api/users/**
filters:
- StripPrefix=1
- id: order-service
uri: lb://order-service
predicates:
- Path=/api/orders/**
filters:
- StripPrefix=1
路由配置类:
@Configuration
public class GatewayConfig {
@Bean
public RouteLocator customRouteLocator(RouteLocatorBuilder builder) {
return builder.routes()
.route("user-service", r -> r
.path("/api/users/**")
.uri("lb://user-service"))
.route("order-service", r -> r
.path("/api/orders/**")
.uri("lb://order-service"))
.build();
}
}
4. 负载均衡(LoadBalancer)
使用 RestTemplate:
@Configuration
public class RestTemplateConfig {
@Bean
@LoadBalanced
public RestTemplate restTemplate() {
return new RestTemplate();
}
}
使用 WebClient:
@Configuration
public class WebClientConfig {
@Bean
@LoadBalanced
public WebClient.Builder webClientBuilder() {
return WebClient.builder();
}
}
服务调用:
@Service
public class OrderService {
private final RestTemplate restTemplate;
public OrderService(@LoadBalanced RestTemplate restTemplate) {
this.restTemplate = restTemplate;
}
public User getUser(Long userId) {
return restTemplate.getForObject(
"http://user-service/api/users/{id}",
User.class,
userId
);
}
}
5. 熔断器(Circuit Breaker)
依赖:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-circuitbreaker-resilience4j</artifactId>
</dependency>
配置:
resilience4j:
circuitbreaker:
instances:
userService:
registerHealthIndicator: true
slidingWindowSize: 10
failureRateThreshold: 50
waitDurationInOpenState: 10000
使用:
@Service
public class OrderService {
private final CircuitBreaker circuitBreaker;
private final RestTemplate restTemplate;
public OrderService(
CircuitBreakerRegistry circuitBreakerRegistry,
RestTemplate restTemplate
) {
this.circuitBreaker = circuitBreakerRegistry.circuitBreaker("userService");
this.restTemplate = restTemplate;
}
public User getUser(Long userId) {
return circuitBreaker.executeSupplier(() ->
restTemplate.getForObject(
"http://user-service/api/users/{id}",
User.class,
userId
)
);
}
}
6. 服务调用(Feign)
依赖:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
启用 Feign:
@SpringBootApplication
@EnableFeignClients
public class OrderServiceApplication {
public static void main(String[] args) {
SpringApplication.run(OrderServiceApplication.class, args);
}
}
定义 Feign Client:
@FeignClient(name = "user-service")
public interface UserServiceClient {
@GetMapping("/api/users/{id}")
User getUserById(@PathVariable Long id);
@PostMapping("/api/users")
User createUser(@RequestBody User user);
}
使用:
@Service
public class OrderService {
private final UserServiceClient userServiceClient;
public OrderService(UserServiceClient userServiceClient) {
this.userServiceClient = userServiceClient;
}
public Order createOrder(Long userId, Order order) {
User user = userServiceClient.getUserById(userId);
// 创建订单逻辑
return order;
}
}
7. 分布式追踪(Sleuth)
依赖:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-sleuth</artifactId>
</dependency>
配置:
spring:
sleuth:
sampler:
probability: 1.0
微服务架构示例
项目结构
microservices/
├── eureka-server/ # 服务注册中心
├── config-server/ # 配置中心
├── gateway/ # API 网关
├── user-service/ # 用户服务
├── order-service/ # 订单服务
└── product-service/ # 商品服务
服务间调用
同步调用(Feign):
@FeignClient(name = "user-service")
public interface UserServiceClient {
@GetMapping("/api/users/{id}")
User getUserById(@PathVariable Long id);
}
异步调用(消息队列):
@Service
public class OrderService {
private final RabbitTemplate rabbitTemplate;
public void publishOrderEvent(Order order) {
rabbitTemplate.convertAndSend("order.exchange", "order.created", order);
}
}
最佳实践
1. 服务拆分
- 按业务领域拆分
- 保持服务独立性
- 避免服务间强耦合
2. 配置管理
- 使用配置中心统一管理
- 区分环境配置
- 支持动态刷新
3. 服务治理
- 使用网关统一入口
- 实现服务熔断和降级
- 监控服务健康状态
4. 数据管理
- 每个服务独立数据库
- 使用 Saga 模式处理分布式事务
- 避免跨服务直接访问数据库
常用依赖
<!-- Eureka Client -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<!-- Gateway -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
<!-- Feign -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<!-- Circuit Breaker -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-circuitbreaker-resilience4j</artifactId>
</dependency>
示例 Prompt
- "如何使用 Spring Cloud 构建微服务架构?"
- "Spring Cloud Gateway 如何配置路由?"
- "如何在 Spring Cloud 中使用 Feign 进行服务调用?"
- "Spring Cloud 中如何实现服务熔断?"
- "如何配置 Spring Cloud Config 配置中心?"
FAQ
What does the spring-cloud skill do?
Provides comprehensive guidance for Spring Cloud microservices including service discovery, configuration management, load balancing, circuit breakers, API gateways, and distributed tracing. Use when the user asks about Spring Cloud, needs to build microservices, implement service discovery, or work with Spring Cloud components.
How do I install spring-cloud?
Run npx skills add https://github.com/full-stack-skills/spring-skills --skill spring-cloud in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/spring-cloud/ (personal) or .claude/skills/spring-cloud/ (project).
Which AI agents can use spring-cloud?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is spring-cloud safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains spring-cloud?
It is published by full-stack-skills in full-stack-skills/spring-skills. It has 202 recorded installs.
More from full-stack-skills/spring-skills
spring-boot
full-stack-skills/spring-skills
Open the skill to read its SKILL.md instructions.
spring-cloud-alibaba
full-stack-skills/spring-skills
Open the skill to read its SKILL.md instructions.
spring-security
full-stack-skills/spring-skills
Open the skill to read its SKILL.md instructions.
spring-data-jpa
full-stack-skills/spring-skills
Open the skill to read its SKILL.md instructions.
spring-ai
full-stack-skills/spring-skills
Open the skill to read its SKILL.md instructions.
spring-ai-alibaba
full-stack-skills/spring-skills
Open the skill to read its SKILL.md instructions.
Popular backend & apis skills
find-skills
vercel-labs/skills
Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. This skill should be used when the user is looking for functionality that might exist as an installable skill.
entra-app-registration
microsoft/azure-skills
Guides Microsoft Entra ID app registration, OAuth 2.0 authentication, and MSAL integration. USE FOR: create app registration, register Azure AD app, configure OAuth, set up authentication, add API permissions, generate service principal, MSAL example, console app auth, Entra ID setup, Azure AD authentication. DO NOT USE FOR: Key Vault secrets (use azure-keyvault-expiration-audit), general Azure resource security guidance.
google-agents-cli-adk-code
google/agents-cli
This skill should be used when the user wants to "write agent code", "build an agent with ADK", "add a tool", "create a callback", "define an agent", "use state management" — in a project that needs ADK (Agent Development Kit) API patterns and code examples. It provides a quick reference for agent types, tool definitions, orchestration patterns, callbacks, state management, the graph Workflow API, and reference recipes to study. Do NOT use for scaffolding (use google-agents-cli-scaffold) or deployment (use google-agents-cli-deploy).
embedded-captions
heygen-com/hyperframes
Add captions or subtitles to an existing single-subject talking-head video without editing the footage. Use for plain verbatim captions, cinematic captions embedded behind the subject, VFX captions, “炸/特效/酷炫字幕,” or a named identity from the 35-style catalog. Route by visual identity, not by backend engine. The quiet anchor rail is the default; embed every word only when the user explicitly wants a fully cinematic treatment. The workflow runs locally end to end, including transcription and subject matting; split multi-shot footage before applying it.
entra-agent-id
microsoft/azure-skills
Provision Microsoft Entra Agent Identity Blueprints, BlueprintPrincipals, and per-instance Agent Identities via Microsoft Graph, and configure OAuth 2.0 token exchange (fmipath, OBO, cross-tenant) including the Microsoft Entra SDK for AgentID sidecar. USE FOR: Agent Identity Blueprint, BlueprintPrincipal, agent OAuth, fmipath token exchange, agent OBO, Workload Identity Federation for agents, polyglot agent auth, Microsoft.Identity.Web.AgentIdentities. DO NOT USE FOR: standard Entra app registration (use entra-app-registration), Microsoft Foundry agent authoring (use microsoft-foundry).
neon
neondatabase/agent-skills
Overview of Neon, a complete set of cloud backend primitives around Lakebase Postgres: Auth, Object Storage, Functions, the AI Gateway, and Realtime. Start here to choose Neon for undecided login, files, APIs, and LLM calls, set up the CLI or MCP server, and follow the branch-first workflow. Use when building an app or backend on Neon, or when "Neon" or "Lakebase Postgres" is mentioned. Child skill neon-postgres wins for an existing DATABASEURL, SQL, schema, inspect, or search. Child skill neon-auth wins for login, users, sessions, identity routing, and Managed Better Auth setup. Child skill neon-realtime wins for live queries in reactive apps and agents. Also use for object storage, S3, buckets, serverless functions, function triggers, cron, AI gateway, LLM calls, realtime, logs, Loki, Grafana, observability, postgres, database, backend, Claimable Neon, neon.new, or a no-signup database.