# Re:0 - Starting Life in Backend - Day7

seal

數不完 見證許願的繁星
沒靈驗 誰來安慰壞心情
十字路口閃爍不停的信號燈
有個人 顯然心事重重
三個字 只能說給自己聽
仰著頭 不要讓眼淚失控
哪裡有可以峰迴路轉的宿命
我不想聽
我吹過你吹過的晚風
那我們算不算相擁
可如夢初醒般的兩手空空
心也空

Extra level 3: Configuring Cloud Ali

Spring Cloud Ali is a framework that provides a one-stop solution for microservice development


Configuring the Initializer

https://start.spring.io/, this one is Spring Boot offical initializer. If you choose to use this initializer, then the version you can choose will be too high.
Spring Cloud Ali didn't provide version to fit Spring boot after 2023, so we need to downgrade version.

Here I suggest to change Intializer as 'https://start.aliyun.com', this Intializer allow you to choose 2.X Spring Boot and Java8.


Dependency Control

SpringBoot, Spring Cloud, and Spring Cloud Alibaba need to meet some strict version checks.

SpringBoot, Spring Cloud, and Spring Cloud Alibaba Version Compatibility Table


Spring Cloud Alibaba Version Spring Cloud Version Spring Boot Version Remarks
2022.0.0.0-RC2* 2022.0.0 3.0.2 Adapts to Spring Boot 3.0, latest version
2022.0.0.0-RC1 2022.0.0 3.0.0 Adapts to Spring Boot 3.0
2021.0.5.0* 2021.0.5 2.6.13 Adapts to Spring Boot 2.4, latest version
2021.0.4.0 2021.0.4 2.6.11 Adapts to Spring Boot 2.4
2021.0.1.0 2021.0.1 2.6.3 Adapts to Spring Boot 2.4
2021.1 2020.0.1 2.4.2 Adapts to Spring Boot 2.4
2.2.10-RC1* Hoxton.SR12 2.3.12.RELEASE Adapts to Spring Boot versions below 2.4, latest version
2.2.9.RELEASE Hoxton.SR12 2.3.12.RELEASE Adapts to Spring Boot versions below 2.4
2.2.8.RELEASE Hoxton.SR12 2.3.12.RELEASE Adapts to Spring Boot versions below 2.4
2.2.7.RELEASE Hoxton.SR12 2.3.12.RELEASE Adapts to Spring Boot versions below 2.4
2.2.6.RELEASE Hoxton.SR9 2.3.2.RELEASE Adapts to Spring Boot versions below 2.4
2.2.1.RELEASE Hoxton.SR3 2.2.5.RELEASE Adapts to Spring Boot versions below 2.4
2.2.0.RELEASE Hoxton.RELEASE 2.2.X.RELEASE Adapts to Spring Boot versions below 2.4
2.1.4.RELEASE Greenwich.SR6 2.1.13.RELEASE Adapts to Spring Boot 2.1.x
2.1.2.RELEASE Greenwich 2.1.X.RELEASE Adapts to Spring Boot 2.1.x
2.0.4.RELEASE Finchley 2.0.X.RELEASE End-of-life, upgrade recommended
1.5.1.RELEASE Edgware 1.5.X.RELEASE End-of-life, upgrade recommended

Key Information:

  • The Spring Cloud Alibaba 2022.x branch (e.g., 2022.0.0.0-RC2) primarily adapts to Spring Boot 3.0.x and Spring Cloud 2022.x versions.
  • The Spring Cloud Alibaba 2021.x branch (e.g., 2021.0.5.0) primarily adapts to Spring Boot 2.4.x / 2.6.x / 2.7.x and Spring Cloud 2021.x versions.
  • The Spring Cloud Alibaba 2.2.x branch (e.g., 2.2.10-RC1) primarily adapts to Spring Boot 2.2.x / 2.3.x and Spring Cloud Hoxton versions.

Choosing the right version combination is crucial for project stability and compatibility.


** Configuration Details**

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.seal</groupId>
    <artifactId>cloud</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>pom</packaging>
    <name>cloud</name>
    <description>cloud</description>
    <modules>
        <module>order</module>
        <module>srock</module>
    </modules>
    <properties>
        <java.version>1.8</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <aliyun-spring-boot.version>1.0.0</aliyun-spring-boot.version>
        <spring-boot.version>2.3.12.RELEASE</spring-boot.version>
        <spring-cloud-alibaba.version>2.2.10-RC1</spring-cloud-alibaba.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>aliyun-rds-spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>aliyun-redis-spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>aliyun-sms-spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
        </dependency>

        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>${spring-boot.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>com.alibaba.cloud</groupId>
                <artifactId>aliyun-spring-boot-dependencies</artifactId>
                <version>${aliyun-spring-boot.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <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>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>${java.version}</source> <target>${java.version}</target> <encoding>${project.build.sourceEncoding}</encoding> </configuration>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>${spring-boot.version}</version>
                <configuration>
                    <skip>true</skip>
                </configuration>
                <executions>
                    <execution>
                        <id>repackage</id>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>