Spring Cloud Alibaba

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

With Ali Cloud, you only need to add some annotations and a little configuration to connect the Spring cloud application to Ali’s distributed solution and build a distributed application system with Ali middleware.

Differences from the previous solution

Spring Cloud Alibaba mainly uses its own components, replacing officially supported Spring Cloud components that are now out of maintenance, closed source, and immature. Thus constitute a better, more lightweight one-stop solution for Alibaba’s microservices architecture.

  • Use Nacos instead of Consul as the service registry.
  • The Ribbon and OpenFeign can still be deployed.
  • Use Sentinel instead of Hystrix as the service protector.
  • The Gateway remains the same as the Spring Cloud Gateway.
  • Spring Cloud Config and Spring Cloud Bus are encapsulated in Nacos to realize configuration repository and automatic configuration refresh.

To sum up, Spring Cloud Alibaba mainly replaces two components in the previous Spring Cloud solution, one component replaces the unified configuration center and service registry, and the other component replaces the protector (circuit breaker). The communication mode and gateway have not changed.

As you can see, using the solution provided by Spring Cloud Alibaba simplifies development better than the Spring Cloud solution provided above.

Basic environment construction

The version number of Spring Cloud Alibaba is no longer an English word, but a general version. This paper mainly describes version 2.2.1.RELEASE, which is compatible with Spring Boot version 2.2.x.

Like Spring Cloud building environment, Spring Cloud Alibaba also supports building from Cloud central library. Once the setup is complete, no dependencies are imported locally, all dependencies are fetched from the cloud.

The configuration framework refers to “Spring Cloud Enterprise Engineering Construction”, and adds the version and central library configuration of Spring Cloud Alibaba on the basis of the original configuration of the parent project, so that Spring Cloud and Spring Cloud Alibaba can be used together. Thus, components in Spring Cloud and components in Spring Cloud Alibaba can be integrated into a set of Spring Cloud Alibaba’s one-stop solution for microservices.

Configure the parent project porm.xml:

<properties>
    <spring.cloud.alibaba.version>2.2.1. RELEASE</spring.cloud.alibaba.version>
</properties>

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