Skip to content
🔴🟠🟡🟢🔵🟣🟤⚫⚪

spirng-cloud-alibaba-demo

简介

这是一个基于spring-cloud-alibaba的脚手架框架,欢迎学习,欢迎star

项目代码仓库地址:https://gitee.com/springzb/spring-cloud-alibaba-demo

此demo主要版信息:

SpringBoot.2.3.12.RELEASE + SpringCloud Hoxton.SR12+ AlibabaCloud 2.2.7.RELEASE

一、版本信息说明:

https://github.com/alibaba/spring-cloud-alibaba/wiki/版本说明

Spring Cloud Alibaba VersionSentinel VersionNacos VersionRocketMQ VersionDubbo VersionSeata Version
2.2.7.RELEASE1.8.12.0.34.6.12.7.131.3.0
Spring Cloud Alibaba VersionSpring Cloud VersionSpring Boot Version
2.2.7.RELEASESpring Cloud Hoxton.SR122.3.12.RELEASE

二、组件说明

SpringCloud

  • 全家桶+轻松嵌入第三方组件(Netflix 奈飞)
  • 官网:https://spring.io/projects/spring-cloud
  • 配套
    • 通信方式:http restful
    • 注册中心:eruka
    • 配置中心:config
    • 断路器:hystrix
    • 网关:zuul/gateway
    • 分布式追踪系统:sleuth+zipkin
  • Spring Alibaba Cloud
    • 全家桶+阿里生态多个组件组合+SpringCloud支持
    • 官网 https://spring.io/projects/spring-cloud-alibaba
    • 配套
      • 通信方式:http restful
      • 注册中心:nacos
      • 配置中心:nacos
      • 断路器:sentinel
      • 网关:gateway
      • 分布式追踪系统:sleuth+zipkin

三、新建聚合工程

3.1父工程pom文件

java
<?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>cn.mesmile</groupId>
    <artifactId>spring-cloud-alibaba-demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <modules>
        <module>cloud-system</module>
        <module>cloud-common</module>
        <module>cloud-order</module>
    </modules>

    <name>spring-cloud-alibaba-demo</name>
    <description>springCloudAlibabaDemo</description>

    <!-- 一般来说父级项目的packaging都为pom,packaging默认类型jar类型-->
    <packaging>pom</packaging>

    <properties>
        <encoding>UTF-8</encoding>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>1.8</java.version>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <lombok.version>1.18.20</lombok.version>
        <spring.boot.version>2.3.12.RELEASE</spring.boot.version>
        <spring.cloud.version>Hoxton.SR12</spring.cloud.version>
        <spring.cloud.alibaba>2.2.7.RELEASE</spring.cloud.alibaba>
        <mybatis.plus.spring.boot>3.4.2</mybatis.plus.spring.boot>
        <file.encoding>UTF-8</file.encoding>
        <log4j2.version>2.17.1</log4j2.version>
    </properties>

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

     Spring Cloud Alibaba Version  Sentinel Version  Nacos Version  RocketMQ Version  Dubbo Version  Seata Version
        2.2.7.RELEASE                   1.8.1           2.0.3               4.6.1           2.7.13          1.3.0

    Spring Cloud Alibaba Version  Spring Cloud Version  Spring Boot Version
        2.2.7.RELEASE                   Hoxton.SR12             2.3.12.RELEASE
    -->

    <dependencies>
<!--        <dependency>-->
<!--            <groupId>org.springframework.boot</groupId>-->
<!--            <artifactId>spring-boot-starter</artifactId>-->
<!--        </dependency>-->

<!--        <dependency>-->
<!--            <groupId>org.springframework.boot</groupId>-->
<!--            <artifactId>spring-boot-starter-test</artifactId>-->
<!--            <scope>test</scope>-->
<!--        </dependency>-->
    </dependencies>

    <!--  dependencyManagement 中的内容是父级项目 用于给子项目引入  -->
    <dependencyManagement>
        <dependencies>
            <!--springboot父依赖-->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>${spring.boot.version}</version>
                <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>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <!-- 如果没有该配置,devtools不会生效
                    Maven 使用 运行自己的 jdk (maven 是需要依赖 jdk 存在的) 来进行 compiler ,
                    如果不想使用这个默认的 jvm,就可以通过 fork 设置为true来实现。-->
                    <fork>true</fork>
                    <addResources>true</addResources>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>