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.
View on GitHubpartme-ai/full-stack-skills
development-skills-utils
February 1, 2026
Select agents to install to:
npx add-skill https://github.com/partme-ai/full-stack-skills/blob/main/skills/spring-cloud/SKILL.md -a claude-code --skill spring-cloudInstallation paths:
.claude/skills/spring-cloud/# Spring Cloud 微服务开发指南
## 概述
Spring Cloud 是一套完整的微服务解决方案,提供了服务注册与发现、配置管理、网关、负载均衡、熔断器等组件。
## 核心组件
### 1. 服务注册与发现(Eureka)
**Eureka Server**:
```java
@SpringBootApplication
@EnableEurekaServer
public class EurekaServerApplication {
public static void main(String[] args) {
SpringApplication.run(EurekaServerApplication.class, args);
}
}
```
**application.yml**:
```yaml
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**:
```java
@SpringBootApplication
@EnableEurekaClient
public class UserServiceApplication {
public static void main(String[] args) {
SpringApplication.run(UserServiceApplication.class, args);
}
}
```
**application.yml**:
```yaml
spring:
application:
name: user-service
eureka:
client:
service-url:
defaultZone: http://localhost:8761/eureka/
```
### 2. 配置中心(Config Server)
**Config Server**:
```java
@SpringBootApplication
@EnableConfigServer
public class ConfigServerApplication {
public static void main(String[] args) {
SpringApplication.run(ConfigServerApplication.class, args);
}
}
```
**application.yml**:
```yaml
server:
port: 8888
spring:
cloud:
config:
server:
git:
uri: https://github.com/example/config-repo
search-paths: '{application}'
```
**Config Client**:
```yaml
spring:
application:
name: user-service
cloud:
config:
uri: http://localhost:8888
name: user-service
profile: dev
```
### 3. API 网关(Gateway)
**Gateway 配置**:
```java
@SpringBootApplication
public class GatewayApplication {
public static void main(String[] args) {
SpringApplication.run(GatewayApplication.class, args);
}
}
```
**application.yml**:
```yaml
spring:
cloud:
gateway:
routes:
- id: user-service