Convert Figma logo to code with AI

alibaba logospring-cloud-alibaba

Spring Cloud Alibaba provides a one-stop solution for application development for the distributed solutions of Alibaba middleware.

27,887
8,320
27,887
313

Top Related Projects

Integration with Netflix OSS components

12,398

AWS Service registry for resilient mid-tier load balancing and failover.

40,439

The java implementation of Apache Dubbo. An RPC and microservice framework.

:fire: Seata is an easy-to-use, high-performance, open source distributed transaction solution.

APM, Application Performance Monitoring System

35,857

Connect, secure, control, and observe services.

Quick Overview

Spring Cloud Alibaba is an open-source project that provides a set of microservices components for building distributed systems. It integrates Alibaba's distributed solutions with Spring Cloud, offering features like service discovery, configuration management, and distributed transaction management.

Pros

  • Seamless integration with Spring Cloud ecosystem
  • Provides robust and battle-tested components from Alibaba's production environment
  • Offers comprehensive documentation and active community support
  • Includes features tailored for cloud-native applications and microservices architecture

Cons

  • Some components may have a learning curve for developers unfamiliar with Alibaba's ecosystem
  • Potential vendor lock-in if heavily relying on Alibaba-specific features
  • May require additional configuration and setup compared to vanilla Spring Cloud
  • Limited adoption outside of China compared to other Spring Cloud implementations

Code Examples

  1. Service Registration and Discovery using Nacos:
@SpringBootApplication
@EnableDiscoveryClient
public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}
  1. Distributed Configuration Management with Nacos:
@RefreshScope
@RestController
public class ConfigController {
    @Value("${config.name}")
    private String name;

    @RequestMapping("/config")
    public String hello() {
        return "config name: " + name;
    }
}
  1. Circuit Breaking with Sentinel:
@RestController
public class EchoController {
    @RequestMapping(value = "/echo/{str}", method = RequestMethod.GET)
    @SentinelResource(value = "echo")
    public String echo(@PathVariable String str) {
        return "echo: " + str;
    }
}

Getting Started

To use Spring Cloud Alibaba, add the following dependency to your pom.xml:

<dependency>
    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-alibaba-dependencies</artifactId>
    <version>${latest.version}</version>
    <type>pom</type>
    <scope>import</scope>
</dependency>

Then, add specific dependencies for the components you want to use, such as:

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

Configure the necessary properties in your application.properties or application.yml file, and you're ready to start using Spring Cloud Alibaba components in your application.

Competitor Comparisons

Integration with Netflix OSS components

Pros of Spring Cloud Netflix

  • More mature and widely adopted in the Spring ecosystem
  • Extensive documentation and community support
  • Broader range of components for microservices architecture

Cons of Spring Cloud Netflix

  • Some components (e.g., Hystrix, Ribbon) are in maintenance mode
  • Higher resource consumption compared to Spring Cloud Alibaba
  • Steeper learning curve for newcomers

Code Comparison

Spring Cloud Netflix (Eureka Client):

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

Spring Cloud Alibaba (Nacos Discovery):

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

Both frameworks offer similar functionality for service discovery, but Spring Cloud Alibaba uses Nacos instead of Eureka. The code structure is nearly identical, with only the annotation differing (@EnableEurekaClient vs. @EnableDiscoveryClient).

Spring Cloud Netflix provides a more comprehensive set of tools for building microservices, but some components are becoming outdated. Spring Cloud Alibaba offers a lightweight alternative with good performance and integration with Alibaba Cloud services, making it an attractive option for projects deployed on Alibaba Cloud or those seeking a more streamlined solution.

12,398

AWS Service registry for resilient mid-tier load balancing and failover.

Pros of Eureka

  • Mature and battle-tested in large-scale production environments
  • Simpler setup and configuration for basic service discovery
  • Well-integrated with other Netflix OSS components

Cons of Eureka

  • Limited features beyond basic service discovery
  • Less active development and updates in recent years
  • Primarily focused on the Java ecosystem

Code Comparison

Eureka client registration:

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

Spring Cloud Alibaba Nacos client registration:

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

Key Differences

  • Spring Cloud Alibaba offers a more comprehensive suite of microservices components, including configuration management, circuit breaking, and messaging
  • Eureka focuses primarily on service discovery, while Spring Cloud Alibaba provides a broader range of features for building distributed systems
  • Spring Cloud Alibaba integrates well with Alibaba Cloud services, making it a strong choice for applications deployed on Alibaba Cloud
  • Eureka has a larger community and more extensive documentation in English, while Spring Cloud Alibaba has strong support in the Chinese developer community

Both projects aim to simplify microservices architecture, but Spring Cloud Alibaba offers a more extensive set of tools and integrations, particularly for Alibaba Cloud users. Eureka remains a solid choice for basic service discovery needs, especially in Netflix OSS-based architectures.

40,439

The java implementation of Apache Dubbo. An RPC and microservice framework.

Pros of Dubbo

  • Lightweight and high-performance RPC framework
  • Supports multiple protocols (e.g., Dubbo, gRPC, REST)
  • Extensive service governance features (load balancing, routing, etc.)

Cons of Dubbo

  • Less integrated with Spring ecosystem compared to Spring Cloud Alibaba
  • Steeper learning curve for developers familiar with Spring Boot/Cloud
  • Limited support for distributed configuration management

Code Comparison

Dubbo service definition:

@Service
public interface UserService {
    User getUser(Long id);
}

Spring Cloud Alibaba service definition:

@FeignClient(name = "user-service")
public interface UserService {
    @GetMapping("/users/{id}")
    User getUser(@PathVariable Long id);

:fire: Seata is an easy-to-use, high-performance, open source distributed transaction solution.

Pros of Seata

  • Focused specifically on distributed transaction management
  • Supports multiple transaction modes (AT, TCC, SAGA, XA)
  • Language-agnostic, can be used with various programming languages

Cons of Seata

  • Narrower scope compared to Spring Cloud Alibaba's comprehensive microservices toolkit
  • May require additional configuration and setup for non-Java applications
  • Less integrated with other Alibaba Cloud services

Code Comparison

Seata (Java):

@GlobalTransactional
public void businessLogic() {
    // Business logic here
}

Spring Cloud Alibaba (Java):

@SentinelResource("resourceName")
@FeignClient(name = "service-provider")
public interface RemoteService {
    @GetMapping("/api/resource")
    String getResource();
}

The code snippets demonstrate the different focus areas of the two projects. Seata provides annotations for managing distributed transactions, while Spring Cloud Alibaba offers a broader set of tools for microservices, including service discovery, load balancing, and circuit breaking.

Spring Cloud Alibaba provides a more comprehensive solution for building microservices on Alibaba Cloud, while Seata focuses specifically on distributed transaction management. The choice between the two depends on the specific requirements of your project and whether you need a full microservices toolkit or a dedicated distributed transaction solution.

APM, Application Performance Monitoring System

Pros of SkyWalking

  • More comprehensive observability solution, including distributed tracing, metrics, and logging
  • Language-agnostic approach, supporting multiple programming languages and frameworks
  • Advanced visualization and analysis tools for better insights into system performance

Cons of SkyWalking

  • Steeper learning curve due to its broader scope and feature set
  • May require more resources for deployment and operation
  • Less integrated with Spring ecosystem compared to Spring Cloud Alibaba

Code Comparison

SkyWalking agent configuration:

agent.service_name=${SW_AGENT_NAME:Your_ApplicationName}
collector.backend_service=${SW_AGENT_COLLECTOR_BACKEND_SERVICES:127.0.0.1:11800}

Spring Cloud Alibaba configuration:

spring:
  cloud:
    nacos:
      discovery:
        server-addr: 127.0.0.1:8848

While both projects aim to improve cloud-native application development, they serve different primary purposes. Spring Cloud Alibaba focuses on providing a comprehensive set of components for building distributed systems using Spring Cloud, while SkyWalking is an APM (Application Performance Monitoring) system that offers observability and monitoring capabilities for various applications and services.

Spring Cloud Alibaba is more tightly integrated with the Spring ecosystem and provides a smoother experience for Spring developers. However, SkyWalking offers a more versatile and language-agnostic approach to observability, making it suitable for heterogeneous environments.

35,857

Connect, secure, control, and observe services.

Pros of Istio

  • More comprehensive service mesh solution with advanced traffic management, security, and observability features
  • Platform-agnostic, supporting multiple environments and languages
  • Larger community and ecosystem, with extensive documentation and integrations

Cons of Istio

  • Steeper learning curve and more complex setup compared to Spring Cloud Alibaba
  • Higher resource overhead, potentially impacting performance in smaller deployments
  • Requires more infrastructure changes and may be overkill for simpler microservices architectures

Code Comparison

Spring Cloud Alibaba (Java):

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

Istio (YAML):

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: my-service
spec:
  hosts:
  - my-service
  http:
  - route:
    - destination:
        host: my-service
        subset: v1

Spring Cloud Alibaba focuses on integrating Alibaba's cloud services with Spring Boot applications, providing a more straightforward approach for Java developers. Istio, on the other hand, offers a more powerful and flexible service mesh solution that works across different platforms and languages, but with increased complexity and resource requirements.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Spring Cloud Alibaba

CircleCI Maven Central License actions Leaderboard

A project maintained by Alibaba.

See the 中文文档 for Chinese readme.

Spring Cloud Alibaba provides a one-stop solution for distributed application development. It contains all the components required to develop distributed applications, making it easy for you to develop your applications using Spring Cloud.

With Spring Cloud Alibaba, you only need to add some annotations and a small amount of configurations to connect Spring Cloud applications to the distributed solutions of Alibaba, and build a distributed application system with Alibaba middleware.

Features

  • Flow control and service degradation: Flow control for HTTP services is supported by default. You can also customize flow control and service degradation rules using annotations. The rules can be changed dynamically.
  • Service registration and discovery: Service can be registered and clients can discover the instances using Spring-managed beans. Load balancing is consistent with that supported by the corresponding Spring Cloud.
  • Distributed configuration: Support for externalized configuration in a distributed system, auto refresh when configuration changes.
  • Event-driven: Support for building highly scalable event-driven microservices connected with shared messaging systems.
  • Distributed Transaction: Support for distributed transaction solution with high performance and ease of use.
  • Alibaba Cloud Object Storage: Massive, secure, low-cost, and highly reliable cloud storage services. Support for storing and accessing any type of data in any application, anytime, anywhere.
  • Alibaba Cloud SchedulerX: Accurate, highly reliable, and highly available scheduled job scheduling services with response time within seconds.
  • Alibaba Cloud SMS: A messaging service that covers the globe, Alibaba SMS provides convenient, efficient, and intelligent communication capabilities that help businesses quickly contact their customers.

For more features, please refer to Roadmap.

In addition to the above-mentioned features, for the needs of enterprise users' scenarios, Microservices Engine (MSE) of Spring Cloud Alibaba's enterprise version provides an enterprise-level microservices governance center, which includes more powerful governance capabilities such as Grayscale Release, Service Warm-up, Lossless Online and Offline and Outlier Ejection. At the same time, it also provides a variety of products and solutions such as enterprise-level Nacos registration / configuration center, enterprise-level cloud native gateway.

Components

Sentinel: Sentinel takes "traffic flow" as the breakthrough point, and provides solutions in areas such as flow control, concurrency, circuit breaking, and load protection to protect service stability.

Nacos: An easy-to-use dynamic service discovery, configuration and service management platform for building cloud native applications.

RocketMQ: A distributed messaging and streaming platform with low latency, high performance and reliability, trillion-level capacity and flexible scalability.

Seata: A distributed transaction solution with high performance and ease of use for microservices architecture.

Alibaba Cloud OSS: An encrypted and secure cloud storage service which stores, processes and accesses massive amounts of data from anywhere in the world.

Alibaba Cloud SMS: A messaging service that covers the globe, Alibaba SMS provides convenient, efficient, and intelligent communication capabilities that help businesses quickly contact their customers.

Alibaba Cloud SchedulerX: Accurate, highly reliable, and highly available scheduled job scheduling services with response time within seconds.

For more features please refer to Roadmap.

How to build

  • 2023.x branch: Corresponds to Spring Cloud 2023 & Spring Boot 3.2.x, JDK 17 or later versions are supported.
  • 2022.x branch: Corresponds to Spring Cloud 2022 & Spring Boot 3.0.x, JDK 17 or later versions are supported.
  • 2021.x branch: Corresponds to Spring Cloud 2021 & Spring Boot 2.6.x. JDK 1.8 or later versions are supported.
  • 2020.0 branch: Corresponds to Spring Cloud 2020 & Spring Boot 2.4.x. JDK 1.8 or later versions are supported.
  • 2.2.x branch: Corresponds to Spring Cloud Hoxton & Spring Boot 2.2.x. JDK 1.8 or later versions are supported.
  • greenwich branch: Corresponds to Spring Cloud Greenwich & Spring Boot 2.1.x. JDK 1.8 or later versions are supported.
  • finchley branch: Corresponds to Spring Cloud Finchley & Spring Boot 2.0.x. JDK 1.8 or later versions are supported.
  • 1.x branch: Corresponds to Spring Cloud Edgware & Spring Boot 1.x, JDK 1.7 or later versions are supported.

Spring Cloud uses Maven for most build-related activities, and you should be able to get off the ground quite quickly by cloning the project you are interested in and typing:

./mvnw install

How to Use

Add maven dependency

These artifacts are available from Maven Central and Spring Release repository via BOM:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-alibaba-dependencies</artifactId>
            <version>2023.0.1.0</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

add the module in dependencies. If you want to choose an older version, you can refer to the Release Notes.

Examples

A spring-cloud-alibaba-examples module is included in our project for you to get started with Spring Cloud Alibaba quickly. It contains an example, and you can refer to the readme file in the example project for a quick walkthrough.

Examples:

Sentinel Example

Nacos Example

RocketMQ Example

Alibaba Cloud OSS Example

Version control guidelines

The version number of the project is in the form of x.x.x, where x is a number, starting from 0, and is not limited to the range 0~9. When the project is in the incubator phase, the version number is 0.x.x.

As the interfaces and annotations of Spring Boot 1 and Spring Boot 2 have been changed significantly in the Actuator module, and spring-cloud-commons is also changed quite a lot from 1.x.x to 2.0.0, we take the same version rule as SpringBoot version number.

  • 1.5.x for Spring Boot 1.5.x
  • 2.0.x for Spring Boot 2.0.x
  • 2.1.x for Spring Boot 2.1.x
  • 2.2.x for Spring Boot 2.2.x
  • 2020.x for Spring Boot 2.4.x
  • 2021.x for Spring Boot 2.6.x
  • 2022.x for Spring Boot 3.0.x
  • 2023.x for Spring Boot 3.2.x

Code of Conduct

This project is a sub-project of Spring Cloud, it adheres to the Contributor Covenant code of conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to spring-code-of-conduct@pivotal.io.

Code Conventions and Housekeeping

None of these is essential for a pull request, but they will all help. They can also be added after the original pull request but before a merge.

Use the Spring Framework code format conventions. If you use Eclipse you can import formatter settings using the eclipse-code-formatter.xml file from the Spring Cloud Build project. If using IntelliJ, you can use the Eclipse Code Formatter Plugin to import the same file.

Make sure all new .java files to have a simple Javadoc class comment with at least an @author tag identifying you, and preferably at least a paragraph on what the class is for.

Add the ASF license header comment to all new .java files (copy from existing files in the project)

Add yourself as an @author to the .java files that you modify substantially (more than cosmetic changes).

Add some Javadocs and, if you change the namespace, some XSD doc elements.

A few unit tests would help a lot as well —— someone has to do it.

If no-one else is using your branch, please rebase it against the current 2023.x (or other target branch in the main project).

When writing a commit message please follow these conventions, if you are fixing an existing issue please add Fixes gh-XXXX at the end of the commit message (where XXXX is the issue number).

Contact Us

Mailing list is recommended for discussing almost anything related to spring-cloud-alibaba.

spring-cloud-alibaba@googlegroups.com: You can ask questions here if you encounter any problem when using or developing spring-cloud-alibaba.