Spring Cloud Alibaba和Spring Cloud 整合主要就是要注意版本之间的互通性。
https://github.com/alibaba/spring-cloud-alibaba/wiki/%E7%89%88%E6%9C%AC%E8%AF%B4%E6%98%8E
这个就是Spring Cloud Alibaba官方提供的版本对照。
1.Spring Cloud Alibaba、Spring Cloud、Spring Boot之间的版本对照
(最新的请点击网址)
2.Spring Cloud Alibaba和其他组建的版本对照
这里要注意你的组建版本和服务版本也要尽量一样(eg:nacos的jar版本和nacos的安装版本不要差距太多,最好是一样的大版本。)
3.创建一个maven项目
mavne配置文件
这里面有很多别的配置,要是不用可以酌情删减
<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>
<packaging>pom</packaging>
<groupId>com.demo</groupId>
<artifactId>demo-roll</artifactId>
<version>1.0.0-SNAPSHOT</version>
<modules>
<!-- 这里是子项目的 artifactId -->
</modules>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>8</java.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<!-- 公共依赖 -->
<lombok.version>1.18.12</lombok.version>
<slf4j.version>1.7.30</slf4j.version>
<fastjson.version>1.2.73</fastjson.version>
<hutool.version>5.7.18</hutool.version>
<easyCaptcha.version>1.6.2</easyCaptcha.version>
<springContext.version>5.2.8.RELEASE</springContext.version>
<!-- 公共依赖 -->
<!-- spring -->
<springboot.version>2.3.2.RELEASE</springboot.version>
<springcloud.version>Hoxton.SR9</springcloud.version>
<springcloud-alibaba.version>2.2.6.RELEASE</springcloud-alibaba.version>
<springboot-elasticsearch.version>2.6.3</springboot-elasticsearch.version>
<springboot-elasticsearch-client.version>7.15.2</springboot-elasticsearch-client.version>
<!-- spring -->
<commons-collections4.version>4.4</commons-collections4.version>
<commons-lang3.version>3.12.0</commons-lang3.version>
<commons-beanutils.version>1.9.4</commons-beanutils.version>
<commons-io.version>2.7</commons-io.version>
<Junit.version>4.13</Junit.version>
<redisson.version>3.13.4</redisson.version>
<mybatisplus.version>3.5.0</mybatisplus.version>
<mybatisplus.generator.version>3.5.1</mybatisplus.generator.version>
<druid.version>1.2.8</druid.version>
<alibabaTTL.version>2.11.5</alibabaTTL.version>
<postgresql.version>42.2.12</postgresql.version>
<jjwt.version>0.9.1</jjwt.version>
<springfox.version>3.0.0</springfox.version>
<easyexcel.version>2.2.6</easyexcel.version>
</properties>
<!-- 公共依赖 -->
<dependencies>
<!-- lombok java工具类库 -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</dependency>
<!-- slf4j java工具类库 -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<!-- fastjson java工具类库 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>${fastjson.version}</version>
</dependency>
<!-- hutool java工具类库 -->
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>${hutool.version}</version>
</dependency>
<!-- 验证码生成工具 -->
<dependency>
<groupId>com.github.whvcse</groupId>
<artifactId>easy-captcha</artifactId>
<version>${easyCaptcha.version}</version>
</dependency>
<!-- springContext -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${springContext.version}</version>
</dependency>
</dependencies>
<!-- 公共依赖 -->
<dependencyManagement>
<dependencies>
<!-- springboot 2.3.12.RELEASE -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${springboot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- springcloud Hoxton.SR12 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${springcloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- springcloud cloud alibaba 2.2.7.RELEASE -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>${springcloud-alibaba.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- 自省和监控的集成功能 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- 注册中心 -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-nacos-discovery</artifactId>
</dependency>
<!-- 配置中心 -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-nacos-config</artifactId>
</dependency>
<!-- 熔断降级 -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
<!-- api网关 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
<!-- elasticsearch -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
<version>${springboot-elasticsearch.version}</version>
</dependency>
<!-- elasticsearch-client -->
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>${springboot-elasticsearch-client.version}</version>
</dependency>
<!--提供了对于JavaBean进行各种操作,克隆对象,属性等等.-->
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>${commons-beanutils.version}</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons-io.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>${commons-collections4.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${Junit.version}</version>
<scope>test</scope>
</dependency>
<!--jsonwebtoken-->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>${jjwt.version}</version>
</dependency>
<!--redisson-->
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson-spring-boot-starter</artifactId>
<version>${redisson.version}</version>
</dependency>
<!--mybatis-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>${mybatisplus.version}</version>
</dependency>
<!--mybatis代码生成器-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
<version>${mybatisplus.generator.version}</version>
</dependency>
<!--druid 连接池-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>${druid.version}</version>
</dependency>
<!--transmittable-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>transmittable-thread-local</artifactId>
<version>${alibabaTTL.version}</version>
</dependency>
<!--PostgreSql-->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgresql.version}</version>
</dependency>
<!--swagger-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${springfox.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${springfox.version}</version>
</dependency>
<!--easyexcel-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>${easyexcel.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<repositories>
<repository>
<id>aliyun</id>
<name>aliyun-maven</name>
<url>https://maven.aliyun.com/repository/central</url>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://maven.aliyun.com/repository/spring</url>
</repository>
</repositories>
</project>
然后创建子项目就可以了