MCPInstall

spring-cloud-alibaba

Provides comprehensive guidance for Spring Cloud Alibaba including Nacos, Sentinel, RocketMQ, and Alibaba Cloud integration. Use when the user asks about Spring Cloud Alibaba, needs to use Alibaba Cloud services, implement service discovery with Nacos, or work with Spring Cloud Alibaba components.

Installs
149
Last 24h
—
Trending rank
—
Security
Not audited

Install

Works with every agent the skills CLI supports.

npx skills add https://github.com/partme-ai/full-stack-skills --skill spring-cloud-alibaba
  1. 01

    Install

    Run the command in your project. The CLI asks which agents to install for.

  2. 02

    Describe the task

    Ask your agent for something this skill covers. It loads spring-cloud-alibaba automatically when relevant.

  3. 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 Alibaba 开发指南

概述

Spring Cloud Alibaba 是阿里巴巴提供的微服务解决方案,提供了 Nacos(服务注册与配置)、Sentinel(流量控制)、RocketMQ(消息队列)、Seata(分布式事务)等组件。

核心组件

1. Nacos(服务注册与配置中心)

Nacos Server 安装:

# 下载 Nacos
wget https://github.com/alibaba/nacos/releases/download/2.2.0/nacos-server-2.2.0.tar.gz

# 解压并启动
tar -xzf nacos-server-2.2.0.tar.gz
cd nacos/bin
sh startup.sh -m standalone

服务注册:

@SpringBootApplication
@EnableDiscoveryClient
public class UserServiceApplication {
    public static void main(String[] args) {
        SpringApplication.run(UserServiceApplication.class, args);
    }
}

application.yml:

spring:
  application:
    name: user-service
  cloud:
    nacos:
      discovery:
        server-addr: localhost:8848
        namespace: dev
        group: DEFAULT_GROUP

配置管理:

spring:
  cloud:
    nacos:
      config:
        server-addr: localhost:8848
        file-extension: yaml
        namespace: dev
        group: DEFAULT_GROUP
        shared-configs:
          - data-id: common-config.yaml
            group: DEFAULT_GROUP
            refresh: true

动态配置刷新:

@RestController
@RefreshScope
public class ConfigController {
    @Value("${app.name:default}")
    private String appName;
    
    @GetMapping("/config")
    public String getConfig() {
        return appName;
    }
}

2. Sentinel(流量控制)

依赖:

<dependency>
    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>

配置:

spring:
  cloud:
    sentinel:
      transport:
        dashboard: localhost:8080
        port: 8719
      datasource:
        flow:
          nacos:
            server-addr: localhost:8848
            dataId: ${spring.application.name}-flow-rules
            groupId: SENTINEL_GROUP
            rule-type: flow

流量控制:

@Service
public class UserService {
    @SentinelResource(value = "getUser", blockHandler = "getUserBlockHandler")
    public User getUser(Long id) {
        return userRepository.findById(id)
            .orElseThrow(() -> new UserNotFoundException(id));
    }
    
    public User getUserBlockHandler(Long id, BlockException ex) {
        return new User(); // 降级处理
    }
}

熔断降级:

@SentinelResource(
    value = "getUser",
    fallback = "getUserFallback",
    blockHandler = "getUserBlockHandler"
)
public User getUser(Long id) {
    // 业务逻辑
}

public User getUserFallback(Long id, Throwable ex) {
    // 降级处理
    return new User();
}

3. RocketMQ(消息队列)

依赖:

<dependency>
    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-starter-alibaba-rocketmq</artifactId>
</dependency>

配置:

spring:
  cloud:
    stream:
      rocketmq:
        binder:
          name-server: localhost:9876
        bindings:
          output:
            producer:
              group: user-service-group

消息发送:

@Service
public class UserService {
    private final RocketMQTemplate rocketMQTemplate;
    
    public UserService(RocketMQTemplate rocketMQTemplate) {
        this.rocketMQTemplate = rocketMQTemplate;
    }
    
    public void sendUserCreatedEvent(User user) {
        rocketMQTemplate.convertAndSend("user-topic", user);
    }
}

消息接收:

@Component
@RocketMQMessageListener(
    topic = "user-topic",
    consumerGroup = "user-consumer-group"
)
public class UserEventListener implements RocketMQListener<User> {
    @Override
    public void onMessage(User user) {
        // 处理消息
        System.out.println("Received user: " + user.getName());
    }
}

4. Seata(分布式事务)

依赖:

<dependency>
    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-starter-alibaba-seata</artifactId>
</dependency>

配置:

spring:
  cloud:
    alibaba:
      seata:
        tx-service-group: my-tx-group
        enabled: true

seata:
  enabled: true
  application-id: ${spring.application.name}
  tx-service-group: my-tx-group
  config:
    type: nacos
    nacos:
      server-addr: localhost:8848
      namespace: ""
      group: SEATA_GROUP
  registry:
    type: nacos
    nacos:
      server-addr: localhost:8848
      namespace: ""
      group: SEATA_GROUP

使用 @GlobalTransactional:

@Service
public class OrderService {
    @GlobalTransactional
    public void createOrder(Order order) {
        // 1. 创建订单
        orderRepository.save(order);
        
        // 2. 扣减库存
        productService.reduceStock(order.getProductId(), order.getQuantity());
        
        // 3. 扣减余额
        accountService.deductBalance(order.getUserId(), order.getAmount());
    }
}

5. Dubbo(RPC 框架)

依赖:

<dependency>
    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-starter-dubbo</artifactId>
</dependency>

配置:

spring:
  cloud:
    dubbo:
      application:
        name: user-service
      registry:
        address: nacos://localhost:8848
      protocol:
        name: dubbo
        port: 20880

服务提供者:

@Service
@org.apache.dubbo.config.annotation.Service
public class UserServiceImpl implements UserService {
    public User getUser(Long id) {
        return userRepository.findById(id).orElseThrow();
    }
}

服务消费者:

@Service
public class OrderService {
    @org.apache.dubbo.config.annotation.Reference
    private UserService userService;
    
    public Order createOrder(Long userId, Order order) {
        User user = userService.getUser(userId);
        // 创建订单逻辑
        return order;
    }
}

微服务架构示例

项目结构

microservices/
├── nacos-server/           # Nacos 服务
├── gateway/                # API 网关
├── user-service/           # 用户服务
├── order-service/          # 订单服务
└── product-service/        # 商品服务

配置示例

统一配置管理:

# Nacos 配置中心
spring:
  cloud:
    nacos:
      config:
        server-addr: localhost:8848
        file-extension: yaml
        namespace: ${spring.profiles.active}
        group: DEFAULT_GROUP
        extension-configs:
          - data-id: common-datasource.yaml
            group: DEFAULT_GROUP
            refresh: true
          - data-id: common-redis.yaml
            group: DEFAULT_GROUP
            refresh: true

最佳实践

1. 服务注册

  • 使用 Nacos 作为服务注册中心
  • 配置合适的命名空间和分组
  • 设置健康检查

2. 配置管理

  • 使用 Nacos 配置中心统一管理
  • 区分环境配置(dev、test、prod)
  • 支持动态刷新

3. 流量控制

  • 使用 Sentinel 进行流量控制
  • 配置限流、熔断、降级规则
  • 监控服务调用情况

4. 分布式事务

  • 使用 Seata 处理分布式事务
  • 合理使用 @GlobalTransactional
  • 避免长事务

常用依赖

<!-- Nacos Discovery -->
<dependency>
    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>

<!-- Nacos Config -->
<dependency>
    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>

<!-- Sentinel -->
<dependency>
    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>

<!-- RocketMQ -->
<dependency>
    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-starter-alibaba-rocketmq</artifactId>
</dependency>

<!-- Seata -->
<dependency>
    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-starter-alibaba-seata</artifactId>
</dependency>

示例 Prompt

  • "如何使用 Spring Cloud Alibaba 构建微服务架构?"
  • "Nacos 如何配置服务注册和配置管理?"
  • "如何在 Spring Cloud Alibaba 中使用 Sentinel 进行流量控制?"
  • "Spring Cloud Alibaba 中如何使用 Seata 处理分布式事务?"
  • "如何配置 RocketMQ 消息队列?"

FAQ

What does the spring-cloud-alibaba skill do?

Provides comprehensive guidance for Spring Cloud Alibaba including Nacos, Sentinel, RocketMQ, and Alibaba Cloud integration. Use when the user asks about Spring Cloud Alibaba, needs to use Alibaba Cloud services, implement service discovery with Nacos, or work with Spring Cloud Alibaba components.

How do I install spring-cloud-alibaba?

Run npx skills add https://github.com/partme-ai/full-stack-skills --skill spring-cloud-alibaba 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-alibaba/ (personal) or .claude/skills/spring-cloud-alibaba/ (project).

Which AI agents can use spring-cloud-alibaba?

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-alibaba 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-alibaba?

It is published by partme-ai in partme-ai/full-stack-skills. It has 149 recorded installs.

More from partme-ai/full-stack-skills

View all →

electron

partme-ai/full-stack-skills

Build cross-platform desktop applications with Electron, covering main/renderer process architecture, IPC communication, BrowserWindow management, menus, tray icons, packaging, and security best practices. Use when the user asks about Electron, needs to create desktop applications, implement Electron features, or build cross-platform desktop apps.

element-plus-vue3

partme-ai/full-stack-skills

Provides comprehensive guidance for Element Plus Vue 3 component library including installation, components, themes, internationalization, and API reference. Use when the user asks about Element Plus for Vue 3, needs to build Vue 3 applications with Element Plus, or customize component styles.

Frontend & Design1.9K installs

uniapp-project

partme-ai/full-stack-skills

Provides per-component and per-API examples with cross-platform compatibility details for uni-app, covering built-in components, uni-ui components, and APIs (network, storage, device, UI, navigation, media). Use when the user needs official uni-app components or APIs, wants per-component examples with doc links, or needs platform compatibility checks.

Frontend & Design902 installs

drawio-flowchart

partme-ai/full-stack-skills

Creates flowcharts, swim lane diagrams, and business process diagrams using Draw.io (diagrams.net). Covers standard flowchart shapes (process, decision, start/end), connectors, auto-layout, and export to PNG/SVG/PDF. Use when the user needs to visualize workflows, decision trees, or business processes.

Business & Finance704 installs

vue3

partme-ai/full-stack-skills

Guidance for Vue 3 using the official guide and API reference. Use when the user needs Vue 3 concepts, patterns, or API details to build components, apps, and tooling.

Frontend & Design637 installs

course-designer

partme-ai/full-stack-skills

Open the skill to read its SKILL.md instructions.

Frontend & Design422 installs

Popular backend & apis skills

View category →

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.

OfficialBackend & APIs4.1M installs

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.

OfficialBackend & APIs566.7K installs

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).

Backend & APIs514.8K installs

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.

Backend & APIs453.3K installs

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).

OfficialBackend & APIs336.6K installs

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.

Backend & APIs237.1K installs