SpringCloud microservice project construction (latest version selection)

Small chat : This time Xiaobai will bring you the detailed steps to build the SpringCloud project. In fact, it is not difficult to create a new project. For novices, what is confusing is about the import of dependencies in pom.xml and the selection of dependent versions. Therefore, next, Xiaobaihui will bring you the dependency selection of the latest official SpringCloudAlibaba project. Of course, Xiaobai will not only talk about the final configuration results, but will remind you how to choose the project version. That is to say, you can Refer to it at any time, so that you can also choose the latest and most suitable dependency version combination in the future. So if you only want SpringCloud microservices, you can. Xiaobai has developed and deployed the SpringCloudAlibaba microservice project, so there is no problem.

Note: What Xiaobai emphasizes here is the latest and most matching dependency version combination, mainly including the version combination of SpringCloudAlibaba series, SpringCloud and SpringBoot. Because the latest version of a certain technology does not necessarily match the latest version of other technologies, it is the "most suitable" combination recommendation. It is recommended based on the official website, so don’t worry, it’s actually very simple, just look at the official website version, and I will post the corresponding website and content recommended by the official website below.


1. Websites related to each technology

1) SpringBoot related

SpringBoot github version address: https://github.com/spring-projects/spring-boot/releases

SpringBoot official website address: https://spring.io/projects/spring-boot/


2) Spring Cloud related

SpringCloud official website address: https://spring.io/projects/spring-cloud


3) Spring Cloud Alibaba related

SpringCloudAlibaba github version address: https://github.com/alibaba/spring-cloud-alibaba/releases

SpringCloud official website address: https://spring.io/projects/spring-cloud-alibaba/


2. SpringCloud microservice project adaptation version recommendation

It is mainly the adaptation with Springboot, because everyone knows that Springboot is a "production" spring project, which automatically manages and integrates many versions of technical dependencies, so we only need to match SpringCloud and SpringBoot here.

Official website recommended URL: https://spring.io/projects/spring-cloud#overview

insert image description here


2.1. More detailed version corresponding viewing method

https://start.spring.io/actuator/info

This is a Json string page, use the online Json formatting tool to view: http://www.jsons.cn/jsoncheck/

{
    
    
    "git": {
    
    
        "branch": "d8ae4573f747cfd71693fb5a41916681b1126aa7", 
        "commit": {
    
    
            "id": "d8ae457", 
            "time": "2022-11-12T16:35:20Z"
        }
    }, 
    "build": {
    
    
        "version": "0.0.1-SNAPSHOT", 
        "artifact": "start-site", 
        "versions": {
    
    
            "spring-boot": "2.7.5", 
            "initializr": "0.20.0-SNAPSHOT"
        }, 
        "name": "start.spring.io website", 
        "time": "2022-11-12T16:38:14.902Z", 
        "group": "io.spring.start"
    }, 
    "bom-ranges": {
    
    
        "codecentric-spring-boot-admin": {
    
    
            "2.4.3": "Spring Boot >=2.3.0.M1 and <2.5.0-M1", 
            "2.5.6": "Spring Boot >=2.5.0.M1 and <2.6.0-M1", 
            "2.6.8": "Spring Boot >=2.6.0.M1 and <2.7.0-M1", 
            "2.7.4": "Spring Boot >=2.7.0.M1 and <3.0.0-M1", 
            "3.0.0-M4": "Spring Boot >=3.0.0-M1 and <3.1.0-M1"
        }, 
        "solace-spring-boot": {
    
    
            "1.1.0": "Spring Boot >=2.3.0.M1 and <2.6.0-M1", 
            "1.2.2": "Spring Boot >=2.6.0.M1 and <3.0.0-M1"
        }, 
        "solace-spring-cloud": {
    
    
            "1.1.1": "Spring Boot >=2.3.0.M1 and <2.4.0-M1", 
            "2.1.0": "Spring Boot >=2.4.0.M1 and <2.6.0-M1", 
            "2.3.2": "Spring Boot >=2.6.0.M1 and <3.0.0-M1"
        }, 
        "spring-cloud": {
    
    
            "Hoxton.SR12": "Spring Boot >=2.2.0.RELEASE and <2.4.0.M1", 
            "2020.0.6": "Spring Boot >=2.4.0.M1 and <2.6.0-M1", 
            "2021.0.0-M1": "Spring Boot >=2.6.0-M1 and <2.6.0-M3", 
            "2021.0.0-M3": "Spring Boot >=2.6.0-M3 and <2.6.0-RC1", 
            "2021.0.0-RC1": "Spring Boot >=2.6.0-RC1 and <2.6.1", 
            "2021.0.5": "Spring Boot >=2.6.1 and <3.0.0-M1", 
            "2022.0.0-M1": "Spring Boot >=3.0.0-M1 and <3.0.0-M2", 
            "2022.0.0-M2": "Spring Boot >=3.0.0-M2 and <3.0.0-M3", 
            "2022.0.0-M3": "Spring Boot >=3.0.0-M3 and <3.0.0-M4", 
            "2022.0.0-M4": "Spring Boot >=3.0.0-M4 and <3.0.0-M5", 
            "2022.0.0-M5": "Spring Boot >=3.0.0-M5 and <3.0.0-RC1", 
            "2022.0.0-RC1": "Spring Boot >=3.0.0-RC1 and <3.1.0-M1"
        }, 
        "spring-cloud-azure": {
    
    
            "4.3.0": "Spring Boot >=2.5.0.M1 and <2.7.0-M1", 
            "4.4.1": "Spring Boot >=2.7.0-M1 and <3.0.0-M1", 
            "6.0.0-beta.3": "Spring Boot >=3.0.0-M1 and <3.1.0-M1"
        }, 
        "spring-cloud-gcp": {
    
    
            "2.0.11": "Spring Boot >=2.4.0-M1 and <2.6.0-M1", 
            "3.4.0": "Spring Boot >=2.6.0-M1 and <3.0.0-M1"
        }, 
        "spring-cloud-services": {
    
    
            "2.3.0.RELEASE": "Spring Boot >=2.3.0.RELEASE and <2.4.0-M1", 
            "2.4.1": "Spring Boot >=2.4.0-M1 and <2.5.0-M1", 
            "3.3.0": "Spring Boot >=2.5.0-M1 and <2.6.0-M1", 
            "3.4.0": "Spring Boot >=2.6.0-M1 and <2.7.0-M1", 
            "3.5.0": "Spring Boot >=2.7.0-M1 and <3.0.0-M1"
        }, 
        "spring-shell": {
    
    
            "2.1.3": "Spring Boot >=2.7.0 and <3.0.0-M1", 
            "3.0.0-M2": "Spring Boot >=3.0.0-M1 and <3.1.0-M1"
        }, 
        "vaadin": {
    
    
            "14.9.1": "Spring Boot >=2.1.0.RELEASE and <2.6.0-M1", 
            "23.2.7": "Spring Boot >=2.6.0-M1 and <2.8.0-M1"
        }, 
        "wavefront": {
    
    
            "2.0.2": "Spring Boot >=2.1.0.RELEASE and <2.4.0-M1", 
            "2.1.1": "Spring Boot >=2.4.0-M1 and <2.5.0-M1", 
            "2.2.2": "Spring Boot >=2.5.0-M1 and <2.7.0-M1", 
            "2.3.0": "Spring Boot >=2.7.0-M1 and <3.0.0-M1"
        }
    }, 
    "dependency-ranges": {
    
    
        "native": {
    
    
            "0.9.0": "Spring Boot >=2.4.3 and <2.4.4", 
            "0.9.1": "Spring Boot >=2.4.4 and <2.4.5", 
            "0.9.2": "Spring Boot >=2.4.5 and <2.5.0-M1", 
            "0.10.0": "Spring Boot >=2.5.0-M1 and <2.5.2", 
            "0.10.1": "Spring Boot >=2.5.2 and <2.5.3", 
            "0.10.2": "Spring Boot >=2.5.3 and <2.5.4", 
            "0.10.3": "Spring Boot >=2.5.4 and <2.5.5", 
            "0.10.4": "Spring Boot >=2.5.5 and <2.5.6", 
            "0.10.5": "Spring Boot >=2.5.6 and <2.5.9", 
            "0.10.6": "Spring Boot >=2.5.9 and <2.6.0-M1", 
            "0.11.0-M1": "Spring Boot >=2.6.0-M1 and <2.6.0-RC1", 
            "0.11.0-M2": "Spring Boot >=2.6.0-RC1 and <2.6.0", 
            "0.11.0-RC1": "Spring Boot >=2.6.0 and <2.6.1", 
            "0.11.0": "Spring Boot >=2.6.1 and <2.6.2", 
            "0.11.1": "Spring Boot >=2.6.2 and <2.6.3", 
            "0.11.2": "Spring Boot >=2.6.3 and <2.6.4", 
            "0.11.3": "Spring Boot >=2.6.4 and <2.6.6", 
            "0.11.5": "Spring Boot >=2.6.6 and <2.7.0-M1", 
            "0.12.0": "Spring Boot >=2.7.0-M1 and <2.7.1", 
            "0.12.1": "Spring Boot >=2.7.1 and <3.0.0-M1"
        }, 
        "okta": {
    
    
            "1.4.0": "Spring Boot >=2.2.0.RELEASE and <2.4.0-M1", 
            "1.5.1": "Spring Boot >=2.4.0-M1 and <2.4.1", 
            "2.0.1": "Spring Boot >=2.4.1 and <2.5.0-M1", 
            "2.1.6": "Spring Boot >=2.5.0-M1 and <3.0.0-M1"
        }, 
        "mybatis": {
    
    
            "2.1.4": "Spring Boot >=2.1.0.RELEASE and <2.5.0-M1", 
            "2.2.2": "Spring Boot >=2.5.0-M1"
        }, 
        "camel": {
    
    
            "3.5.0": "Spring Boot >=2.3.0.M1 and <2.4.0-M1", 
            "3.10.0": "Spring Boot >=2.4.0.M1 and <2.5.0-M1", 
            "3.13.0": "Spring Boot >=2.5.0.M1 and <2.6.0-M1", 
            "3.17.0": "Spring Boot >=2.6.0.M1 and <2.7.0-M1", 
            "3.19.0": "Spring Boot >=2.7.0.M1 and <3.0.0-M1"
        }, 
        "picocli": {
    
    
            "4.6.3": "Spring Boot >=2.4.0.RELEASE and <3.0.0-M1"
        }, 
        "open-service-broker": {
    
    
            "3.2.0": "Spring Boot >=2.3.0.M1 and <2.4.0-M1", 
            "3.3.1": "Spring Boot >=2.4.0-M1 and <2.5.0-M1", 
            "3.4.1": "Spring Boot >=2.5.0-M1 and <2.6.0-M1", 
            "3.5.0": "Spring Boot >=2.6.0-M1 and <2.7.0-M1"
        }
    }
}

2.2. Recommended use

Just use the latest if you only use SpringBoot.

If you use the SpringCloud microservice project, SpringCloud uses the latest version, and SpringBoot finds the most suitable version.


3. Spring Cloud Alibaba product version recommendation

The dependent version of Spring Cloud Alibaba integrates Alibaba's own version collection related to the Spring Cloud development framework, including nacos, seata, sentinel, rocketmq, etc. When using these products, they must correspond to the Spring Cloud version, so if you want to use the latest For SpringCloudAlibaba products, you need to select the latest version that SpringCloudAlibaba depends on first, and then select the versions of SpringCloud and SpringBoot. (Because SpringCloudAlibaba is definitely not as fast as they are updated)

Official version description URL:
https://github.com/alibaba/spring-cloud-alibaba/wiki/%E7%89%88%E6%9C%AC%E8%AF%B4%E6%98%8E

The following is the official text, I took it directly~


3.1. Graduation version dependencies (recommended)

Due to the large changes between Spring Boot 2.4+ and the following versions, the current Spring Boot version related to the old projects of enterprise customers is still below Spring Boot 2.4. In order to meet the different needs of existing users and new users at the same time, the community is divided into Spring Boot 2.4 Boundary, while maintaining two branch iterations of 2.2.x and 2021.x.

1) 2021.x branch

The versions of Spring Cloud Alibaba adapted to Spring Boot 2.4, Spring Cloud 2021.x and above are arranged in the following table from newest to old (the latest version is marked with *): (Note that the naming method of this branch Spring Cloud Alibaba version has been adjusted. In the future It will correspond to the Spring Cloud version, the first three digits are the Spring Cloud version, and the last digit is the extended version. For example, the first version of Spring Cloud Alibaba corresponding to the Spring Cloud 2021.0.1 version is: 2021.0.1.0, and the second version is : 2021.0.1.1, and so on)

Spring Cloud Alibaba Version Spring Cloud Version Spring Boot Version
2021.0.4.0* Spring Cloud 2021.0.4 2.6.11
2021.0.1.0 Spring Cloud 2021.0.1 2.6.3
2021.1 Spring Cloud 2020.0.1 2.4.2

2) 2.2.x branch

Adapted to Spring Boot 2.4, the Spring Cloud Hoxton version and the following Spring Cloud Alibaba version are arranged in the following table from newest to old (the latest version is marked with *):

Spring Cloud Alibaba Version Spring Cloud Version Spring Boot Version
2.2.9.RELEASE* Spring Cloud Hoxton.SR12 2.3.12.RELEASE
2.2.8.RELEASE Spring Cloud Hoxton.SR12 2.3.12.RELEASE
2.2.7.RELEASE Spring Cloud Hoxton.SR12 2.3.12.RELEASE
2.2.6.RELEASE Spring Cloud Hoxton.SR9 2.3.2.RELEASE
2.2.1.RELEASE Spring Cloud Hoxton.SR3 2.2.5.RELEASE
2.2.0.RELEASE Spring Cloud Hoxton.RELEASE 2.2.X.RELEASE
2.1.4.RELEASE Spring Cloud Greenwich.SR6 2.1.13.RELEASE
2.1.2.RELEASE Spring Cloud Greenwich 2.1.X.RELEASE
2.0.4.RELEASE (stop maintenance, upgrade is recommended) Spring Cloud Finchley 2.0.X.RELEASE
1.5.1.RELEASE (stop maintenance, upgrade is recommended) Spring Cloud Edgware 1.5.X.RELEASE

3.2. Component version relationship

Each version of Spring Cloud Alibaba and the corresponding version of each component it adapts to is shown in the following table (note that Spring Cloud Dubbo has been removed from the trunk since 2021.0.1.0 and will no longer evolve with the trunk):

Spring Cloud Alibaba Version Sentinel Version Nacos Version RocketMQ Version Dubbo Version Seata Version
2.2.9.RELEASE 1.8.5 2.1.0 4.9.4 ~ 1.5.2
2021.0.4.0 1.8.5 2.0.4 4.9.4 ~ 1.5.2
2.2.8.RELEASE 1.8.4 2.1.0 4.9.3 ~ 1.5.1
2021.0.1.0 1.8.3 1.4.2 4.9.2 ~ 1.4.2
2.2.7.RELEASE 1.8.1 2.0.3 4.6.1 2.7.13 1.3.0
2.2.6.RELEASE 1.8.1 1.4.2 4.4.0 2.7.8 1.3.0
2021.1 or 2.2.5.RELEASE or 2.1.4.RELEASE or 2.0.4.RELEASE 1.8.0 1.4.1 4.4.0 2.7.8 1.3.0
2.2.3.RELEASE or 2.1.3.RELEASE or 2.0.3.RELEASE 1.8.0 1.3.3 4.4.0 2.7.8 1.3.0
2.2.1.RELEASE or 2.1.2.RELEASE or 2.0.2.RELEASE 1.7.1 1.2.1 4.4.0 2.7.6 1.2.0
2.2.0.RELEASE 1.7.1 1.1.4 4.4.0 2.7.4.1 1.0.0
2.1.1.RELEASE or 2.0.1.RELEASE or 1.5.1.RELEASE 1.7.0 1.1.4 4.4.0 2.7.3 0.9.0
2.1.0.RELEASE or 2.0.0.RELEASE or 1.5.0.RELEASE 1.6.3 1.1.1 4.4.0 2.7.3 0.7.1

4. Example: Create the latest SpringCloudAlibaba microservice project

Wow, I'm finally here... Here we take the latest and most suitable version of SpringCloud microservices with SpringCloudAlibaba products as an example. If you just want SpringCloud microservice projects, you can refer to the following examples according to the official recommendation above. Configure and build.


4.1. Create a new parent project project, using the simplest Maven project

1) Select the initial framework of the Maven project, the jdk version, name it, and specify the location

Initial framework: org.apache.maven.archetypes:maven-archetype-site

jdk version: jkd1.8

Name: SpringCloud2022

insert image description here


2) Open File ——> Settings, search for Maven, and specify the path to install Maven yourself to facilitate the import of pom coordinates files

insert image description here


3) Use the prepared pom.xml file of the parent project to specify the main environment of the prepared SpringCloud version. The following is the content of the prepared pom.xml file

<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.byy.springbloud</groupId>
    <artifactId>SpringCloud2022</artifactId>
    <version>1.0-SNAPSHOT</version>
    <modules>
        <module>user-service</module>
    </modules>
    <!-- 修改打包方式 -->
    <packaging>pom</packaging>

    <properties>
        <java.version>1.8</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <!-- 2022.11.16 SpringCloudAlibaba2021.x 最新适配版3SpringXXX搭配 -->
        <spring-boot.version>2.6.11</spring-boot.version>
        <spring-cloud.version>2021.0.4</spring-cloud.version>
        <spring-cloud-alibaba.version>2021.0.4.0</spring-cloud-alibaba.version>
        <!-- mybatis-plus 选择版本适配spring-boot -->
        <mybatis-plus.version>3.5.1</mybatis-plus.version>
        <!-- 2022.11.16 SpringCloudAlibaba2.2.x 最新适配版3SpringXXX搭配 -->
        <!--    <spring-boot.version>2.3.12.RELEASE</spring-boot.version>-->
        <!--    <spring-cloud.version>Hoxton.SR12</spring-cloud.version>-->
        <!--    <spring-cloud-alibaba.version>2.2.9.RELEASE</spring-cloud-alibaba.version>-->
        <!--    <mybatis-plus.version>3.4.2</mybatis-plus.version>-->
        <mysql.version>8.0.22</mysql.version>
        <fastjson.version>2.0.18</fastjson.version>
        <junit.version>4.13.2</junit.version>
        <lombok.version>1.18.24</lombok.version>
        <log4j.version>1.2.17</log4j.version>
    </properties>

    <!--  因为是总项目 所以用dependencyManagement来管理;其他的子项目就不会来管理版本了了 可以直接引用 -->
    <dependencyManagement>
        <dependencies>
            <!-- springBoot -->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>${spring-boot.version}</version>
                <!-- type和scope标签:让子model可以多继承父model -->
                <!-- <type></type> 里的值默认值是jar表示引入的是jar包,这里使用的是pom表示导入的是父模块; -->
                <!-- <scope></scope>中的值import代表把父模块中的jar包导入进来,不过需要注意的是<scope>import</scope>, -->
                <!-- 这种方式只能用在<dependencyManagement></dependencyManagement>中。 -->
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <!-- springCloud -->
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <!-- springCloudAlibaba -->
            <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>
            <!-- mysql驱动 -->
            <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
                <version>${mysql.version}</version>
            </dependency>
            <!-- mybatis-plus -->
            <dependency>
                <groupId>com.baomidou</groupId>
                <artifactId>mybatis-plus-boot-starter</artifactId>
                <version>${mybatis-plus.version}</version>
            </dependency>
            <!-- Java对象和JSON相互转换 -->
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>fastjson</artifactId>
                <version>${fastjson.version}</version>
            </dependency>
            <!-- JavaBean 注解构建 -->
            <dependency>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
                <version>${lombok.version}</version>
                <optional>true</optional>
            </dependency>
            <!-- 测试 -->
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>${junit.version}</version>
            </dependency>
            <!-- 日志 -->
            <dependency>
                <groupId>log4j</groupId>
                <artifactId>log4j</artifactId>
                <version>${log4j.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>
</project>

4.2. Create a new subproject

1) Select the new submodule Maven project

insert image description here

Oh, let me tell you, the src directory in the parent project is useless and deleted, it is an eyesore, and the .idea directory is hidden, so it is fine. How to hide Go to Settings --> Editor --> File Types, click on the "Ignored Files and Folders" column, there are other hidden file formats, follow suit, such as adding *.idea

insert image description here


2) Configure Maven subproject settings

It is best to choose the Maven project here instead of the Spring Initializer. This is indeed used to create a new SpringBoot/SpringCloud project, but it will not default to a submodule. In other words, it will be an independent project. However, it is only in the parent project directory we created before, but it will not be automatically configured to inherit the pom coordinates of the parent project. We have to add the submodule <modules>label It is best to choose the Maven project, which will be configured as a submodule by default, and there are no dependent coordinates in pom.xml, and you can add whatever you want at any time.

insert image description here

I chose org.apache.maven.archetypes:maven-archetype-webapp as the framework here. This is a web framework. I just fancy it and it will help me build the directory structure of the web project. Of course, if it is not a web function module If so, choose another framework. In short, you can change it yourself in the end, don't be too entangled.


3) Modify the pom.xml configuration of the submodule user-serivice

Well, you have to import dependencies according to your own sub-project requirements. I will write more below, and you may not use so many. You can use it as a reference.

<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 http://maven.apache.org/maven-v4_0_0.xsd">
    <parent>
        <artifactId>SpringCloud2022</artifactId>
        <groupId>com.byy.springbloud</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <!-- 模块名称 -->
    <artifactId>user-service</artifactId>

    <!-- 注意,子项目模块就是 dependencies 了,是真正需要导入包的,版本则不需要指定 -->
    <dependencies>
        <!-- Web开发 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <!-- SpringBoot应用的监控 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <!-- SpringBoot测试 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
        </dependency>
        <!-- springboot统一封装的消息中间件框架 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-amqp</artifactId>
        </dependency>
        <!-- mongodb -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-mongodb</artifactId>
        </dependency>
        <!-- redis -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
        </dependency>
        <!--引入es的RestHighLevelClient依赖-->
        <dependency>
            <groupId>org.elasticsearch.client</groupId>
            <artifactId>elasticsearch-rest-high-level-client</artifactId>
        </dependency>
        <!-- nacos客户端依赖包 -->
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
        </dependency>
        <!--nacos的配置管理依赖-->
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
        </dependency>
        <!-- 配置sentinel规则持久化,引入sentinel监听nacos的依赖 -->
        <!-- 为了减少开发的复杂程度,Sentinel 对大部分的主流框架做了适配, -->
        <!-- 例如 SpringMVC、WebFlux、Dubbo、Spring Cloud、RocketMQ 等等。 -->
        <!-- 我们只需要引入对应的 sentinel-apache-xxx-adapter 依赖,即可方便地整合 Sentinel。 -->
        <dependency>
            <groupId>com.alibaba.csp</groupId>
            <artifactId>sentinel-datasource-nacos</artifactId>
        </dependency>
        <!-- sentinel微服务保护 -->
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
        </dependency>
        <!-- 配置spring-webmvc集成sentinel,做web监控 -->
        <dependency>
            <groupId>com.alibaba.csp</groupId>
            <artifactId>sentinel-spring-webmvc-adapter</artifactId>
        </dependency>
        <!-- gateway网关 -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-gateway</artifactId>
        </dependency>
        <!-- seata全局事务控制 -->
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-seata</artifactId>
        </dependency>
        <!-- openfeign RPC远程调用 -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-openfeign</artifactId>
        </dependency>
        <!-- kafka 消息中间件 -->
        <dependency>
            <groupId>org.springframework.kafka</groupId>
            <artifactId>spring-kafka</artifactId>
        </dependency>
        <!-- springboot热部署 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <!-- ojdbc8 -->
        <dependency>
            <groupId>com.oracle.database.jdbc</groupId>
            <artifactId>ojdbc8</artifactId>
            <scope>runtime</scope>
        </dependency>
        <!-- mysql -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <!-- Java对象和JSON相互转换 -->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
        </dependency>
        <!-- JavaBean 注解构建 -->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <!-- 测试 -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
        </dependency>
        <!-- 日志 -->
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
        </dependency>
    </dependencies>

    <!-- 每个子项目可单独打包然后分发到各自服务器部署 -->
    <build>
        <!-- 文件项目打包名字,不设置默认是artifactId与version拼接的结果 -->
        <finalName>user-service</finalName>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <!-- 热部署配置需添加以下configuration,不加该配置可能不会生效。不需要热部署可以去掉 -->
                <configuration>
                    <fork>true</fork>
                    <addResources>true</addResources>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

Well, the basic configuration of a microservice project is completed, and it will be fine to add more sub-projects.


essay

insert image description here

Guess you like

Origin blog.csdn.net/m0_48489737/article/details/127877096