本篇文章是从Seata官方样例改造而来的分布式事务,Nacos为服务的注册中心及配置中心,这里我采用的组件的版本为:Nacos 2.1.0、Seata 1.5.2
Seata的官方样例库为:https://github.com/seata/seata-samples
样例的结构如下:
启动seata服务让seata服务注册到Nacos上。
1.POM文件内容
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<spring-cloud.version>2021.0.4</spring-cloud.version>
<cloud.alibaba.version>2021.0.4.0</cloud.alibaba.version>
<nacos.version>2.1.0</nacos.version>
<cloud.version>3.1.2</cloud.version>
<druid.version>1.2.11</druid.version>
<dynamic-datasource.version>3.5.1</dynamic-datasource.version>
<mybatis-plus.version>3.5.2</mybatis-plus.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>${cloud.alibaba.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-client</artifactId>
<version>2.1.1</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
<version>3.1.4</version>
</dependency<