注意版本:示例中使用的框架为 Spring Boot + Mybatis-Plus + Dubbo + Seata
虽然Seata最新版本是1.5.2,Dubbo最新版本为3.1.1,但这这两个版本中二者不兼容 , 可以降低其中一个的版本 , 比如
Seata 1.4.2 + Dubbo 3.1.1 或者 Seata 1.5.2 + Dubbo 2.7.18
本示例中采用的是 seata-spring-boot-starter 1.5.2 + dubbo 2.7.18
工程结构如图
文章插图
父pom.xml如下
<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.cjs.example</groupId><artifactId>seata-spring-boot-starter-samples</artifactId><version>1.0-SNAPSHOT</version><packaging>pom</packaging><name>seata-spring-boot-starter-samples</name><modules><module>samples-common-service</module><module>samples-stock-service</module><module>samples-order-service</module><module>samples-account-service</module><module>samples-business-service</module></modules><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><spring-boot.version>2.7.5</spring-boot.version><dubbo.version>2.7.18</dubbo.version><seata.version>1.5.2</seata.version><mybatis-plus.version>3.5.2</mybatis-plus.version></properties><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><optional>true</optional></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>org.apache.dubbo</groupId><artifactId>dubbo-dependencies-bom</artifactId><version>${dubbo.version}</version><type>pom</type><scope>import</scope></dependency>--><dependency><groupId>org.apache.dubbo</groupId><artifactId>dubbo</artifactId><version>${dubbo.version}</version></dependency><dependency><groupId>org.apache.dubbo</groupId><artifactId>dubbo-spring-boot-starter</artifactId><version>${dubbo.version}</version></dependency><dependency><groupId>org.apache.dubbo</groupId><artifactId>dubbo-registry-nacos</artifactId><version>${dubbo.version}</version></dependency><dependency><groupId>io.seata</groupId><artifactId>seata-spring-boot-starter</artifactId><version>${seata.version}</version></dependency><dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-boot-starter</artifactId><version>${mybatis-plus.version}</version></dependency></dependencies></dependencyManagement></project>
子pom.xml如下,其它几个类似不再重复:<?xml version="1.0" encoding="UTF-8"?><projectxmlns="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><parent><groupId>com.cjs.example</groupId><artifactId>seata-spring-boot-starter-samples</artifactId><version>1.0-SNAPSHOT</version></parent><groupId>com.cjs.example</groupId><artifactId>samples-order-service</artifactId><version>${parent.version}</version><name>samples-order-service</name><properties><java.version>1.8</java.version></properties><dependencies><dependency><groupId>com.cjs.example</groupId><artifactId>samples-common-service</artifactId><version>${parent.version}</version></dependency><dependency><groupId>org.apache.dubbo</groupId><artifactId>dubbo</artifactId></dependency><dependency><groupId>org.apache.dubbo</groupId><artifactId>dubbo-spring-boot-starter</artifactId></dependency><dependency><groupId>org.apache.dubbo</groupId><artifactId>dubbo-registry-nacos</artifactId></dependency><dependency><groupId>io.seata</groupId><artifactId>seata-spring-boot-starter</artifactId></dependency><dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-boot-starter</artifactId></dependency><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><scope>runtime</scope></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency></dependencies><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins></build></project>
推荐阅读
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Rock18框架之整体框架介绍
- 支持JDK19虚拟线程的web框架,之二:完整开发一个支持虚拟线程的quarkus应用
- 「MySQL高级篇」MySQL之MVCC实现原理&&事务隔离级别的实现
- [Pyhton] SimPy 离散事件模拟框架详解 —— 以一个简单的汽车充电排队模拟为例
- 20 基于SqlSugar的开发框架循序渐进介绍-- 在基于UniApp+Vue的移动端实现多条件查询的处理
- 弹性分布式数据集 RDD及常用算子
- 分布式ID生成方案总结整理
- 「MySQL高级篇」MySQL锁机制 && 事务
- 说说 Redis 事务
- Spring事务传播行为实战