> getDatasource() {
return datasource;
}
@@ -890,4 +903,38 @@ public class MybatisFlexProperties {
}
+ /**
+ * Seata 配置
+ *
+ * @author life
+ */
+ public static class SeataConfig{
+
+ /**
+ * 是否开启
+ */
+ private boolean enable = false;
+
+ /**
+ * 事务模式支持,只支持XA或者AT
+ */
+ private SeataMode seataMode = SeataMode.AT;
+
+ public boolean isEnable() {
+ return enable;
+ }
+
+ public void setEnable(boolean enable) {
+ this.enable = enable;
+ }
+
+ public SeataMode getSeataMode() {
+ return seataMode;
+ }
+
+ public void setSeataMode(SeataMode seataMode) {
+ this.seataMode = seataMode;
+ }
+ }
+
}
diff --git a/mybatis-flex-spring-boot-starter/src/main/java/com/mybatisflex/spring/boot/SeataMode.java b/mybatis-flex-spring-boot-starter/src/main/java/com/mybatisflex/spring/boot/SeataMode.java
new file mode 100644
index 00000000..b02af607
--- /dev/null
+++ b/mybatis-flex-spring-boot-starter/src/main/java/com/mybatisflex/spring/boot/SeataMode.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.mybatisflex.spring.boot;
+
+/**
+ * @author life
+ */
+public enum SeataMode {
+
+ XA,
+
+ AT
+}
diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-seata/pom.xml b/mybatis-flex-test/mybatis-flex-spring-boot-seata/pom.xml
new file mode 100644
index 00000000..6e1055b1
--- /dev/null
+++ b/mybatis-flex-test/mybatis-flex-spring-boot-seata/pom.xml
@@ -0,0 +1,155 @@
+
+
+ 4.0.0
+
+ mybatis-flex-test
+ com.mybatis-flex
+ 1.5.6
+
+ com.mybatisfle.test
+ mybatis-flex-spring-boot-seata
+ 0.0.1-SNAPSHOT
+ mybatis-flex-spring-boot-seata
+ mybatis-flex-spring-boot-seata
+
+ 1.8
+
+
+
+ com.mybatis-flex
+ mybatis-flex-spring-boot-starter
+ ${mybatis-flex.version}
+
+
+
+ com.mybatis-flex
+ mybatis-flex-codegen
+ 1.5.6
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ com.alibaba.fastjson2
+ fastjson2
+ 2.0.32
+
+
+
+ com.alibaba
+ druid-spring-boot-starter
+ 1.2.18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-jdbc
+
+
+
+ com.mysql
+ mysql-connector-j
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.projectlombok
+ lombok
+ RELEASE
+ compile
+
+
+
+ io.seata
+ seata-spring-boot-starter
+ 1.7.0
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+ org.projectlombok
+ lombok
+
+
+
+
+
+
+
+
+ spring-milestones
+ Spring Milestones
+ https://repo.spring.io/milestone
+
+ false
+
+
+
+ spring-snapshots
+ Spring Snapshots
+ https://repo.spring.io/snapshot
+
+ false
+
+
+
+
+
+ spring-milestones
+ Spring Milestones
+ https://repo.spring.io/milestone
+
+ false
+
+
+
+ spring-snapshots
+ Spring Snapshots
+ https://repo.spring.io/snapshot
+
+ false
+
+
+
+
+
diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/MybatisFlexSpringBootSeataApplication.java b/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/MybatisFlexSpringBootSeataApplication.java
new file mode 100644
index 00000000..142a5773
--- /dev/null
+++ b/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/MybatisFlexSpringBootSeataApplication.java
@@ -0,0 +1,15 @@
+package com.mybatisfle.test.mybatisflexspringbootseata;
+
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@MapperScan("com.mybatisfle.test.mybatisflexspringbootseata")
+@SpringBootApplication
+public class MybatisFlexSpringBootSeataApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(MybatisFlexSpringBootSeataApplication.class, args);
+ }
+
+}
diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/controller/TestController.java b/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/controller/TestController.java
new file mode 100644
index 00000000..b32d80b5
--- /dev/null
+++ b/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/controller/TestController.java
@@ -0,0 +1,28 @@
+package com.mybatisfle.test.mybatisflexspringbootseata.controller;
+
+import com.mybatisfle.test.mybatisflexspringbootseata.service.TestService;
+import com.mybatisflex.core.audit.AuditManager;
+import com.mybatisflex.core.audit.ConsoleMessageCollector;
+import com.mybatisflex.core.audit.MessageCollector;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+@Controller
+public class TestController {
+
+
+ @Autowired
+ TestService testService;
+
+ @RequestMapping("buy")
+ public String buy(){
+ //开启审计功能
+ AuditManager.setAuditEnable(true);
+//设置 SQL 审计收集器
+ MessageCollector collector = new ConsoleMessageCollector();
+ AuditManager.setMessageCollector(collector);
+ String flag =String.valueOf(testService.buy());
+ return flag;
+ }
+}
diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/entity/AccountTbl.java b/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/entity/AccountTbl.java
new file mode 100644
index 00000000..ee716d42
--- /dev/null
+++ b/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/entity/AccountTbl.java
@@ -0,0 +1,51 @@
+package com.mybatisfle.test.mybatisflexspringbootseata.entity;
+
+import com.mybatisflex.annotation.Id;
+import com.mybatisflex.annotation.KeyType;
+import com.mybatisflex.annotation.Table;
+import java.io.Serializable;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * 实体类。
+ *
+ * @author life
+ * @since 2023-08-03
+ */
+@Table(value = "account_tbl", schema = "db_account")
+public class AccountTbl implements Serializable {
+
+ @Id(keyType = KeyType.Auto)
+ private Integer id;
+
+ private String userId;
+
+ private Integer money;
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getUserId() {
+ return userId;
+ }
+
+ public void setUserId(String userId) {
+ this.userId = userId;
+ }
+
+ public Integer getMoney() {
+ return money;
+ }
+
+ public void setMoney(Integer money) {
+ this.money = money;
+ }
+}
diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/entity/OrderTbl.java b/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/entity/OrderTbl.java
new file mode 100644
index 00000000..8f5b7c2f
--- /dev/null
+++ b/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/entity/OrderTbl.java
@@ -0,0 +1,71 @@
+package com.mybatisfle.test.mybatisflexspringbootseata.entity;
+
+import com.mybatisflex.annotation.Id;
+import com.mybatisflex.annotation.KeyType;
+import com.mybatisflex.annotation.Table;
+import java.io.Serializable;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * 实体类。
+ *
+ * @author life
+ * @since 2023-08-03
+ */
+@Table(value = "order_tbl", schema = "db_order")
+public class OrderTbl implements Serializable {
+
+ @Id(keyType = KeyType.Auto)
+ private Integer id;
+
+ private String userId;
+
+ private String commodityCode;
+
+ private Integer count;
+
+ private Integer money;
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getUserId() {
+ return userId;
+ }
+
+ public void setUserId(String userId) {
+ this.userId = userId;
+ }
+
+ public String getCommodityCode() {
+ return commodityCode;
+ }
+
+ public void setCommodityCode(String commodityCode) {
+ this.commodityCode = commodityCode;
+ }
+
+ public Integer getCount() {
+ return count;
+ }
+
+ public void setCount(Integer count) {
+ this.count = count;
+ }
+
+ public Integer getMoney() {
+ return money;
+ }
+
+ public void setMoney(Integer money) {
+ this.money = money;
+ }
+}
diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/entity/StockTbl.java b/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/entity/StockTbl.java
new file mode 100644
index 00000000..f452cdec
--- /dev/null
+++ b/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/entity/StockTbl.java
@@ -0,0 +1,51 @@
+package com.mybatisfle.test.mybatisflexspringbootseata.entity;
+
+import com.mybatisflex.annotation.Id;
+import com.mybatisflex.annotation.KeyType;
+import com.mybatisflex.annotation.Table;
+import java.io.Serializable;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * 实体类。
+ *
+ * @author life
+ * @since 2023-08-03
+ */
+@Table(value = "stock_tbl", schema = "db_stock")
+public class StockTbl implements Serializable {
+
+ @Id(keyType = KeyType.Auto)
+ private Integer id;
+
+ private String commodityCode;
+
+ private Integer count;
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getCommodityCode() {
+ return commodityCode;
+ }
+
+ public void setCommodityCode(String commodityCode) {
+ this.commodityCode = commodityCode;
+ }
+
+ public Integer getCount() {
+ return count;
+ }
+
+ public void setCount(Integer count) {
+ this.count = count;
+ }
+}
diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/mapper/AccountTblMapper.java b/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/mapper/AccountTblMapper.java
new file mode 100644
index 00000000..f6a9cdd5
--- /dev/null
+++ b/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/mapper/AccountTblMapper.java
@@ -0,0 +1,15 @@
+package com.mybatisfle.test.mybatisflexspringbootseata.mapper;
+
+
+import com.mybatisfle.test.mybatisflexspringbootseata.entity.AccountTbl;
+import com.mybatisflex.core.BaseMapper;
+
+/**
+ * 映射层。
+ *
+ * @author life
+ * @since 2023-08-03
+ */
+public interface AccountTblMapper extends BaseMapper {
+
+}
diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/mapper/OrderTblMapper.java b/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/mapper/OrderTblMapper.java
new file mode 100644
index 00000000..56983337
--- /dev/null
+++ b/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/mapper/OrderTblMapper.java
@@ -0,0 +1,15 @@
+package com.mybatisfle.test.mybatisflexspringbootseata.mapper;
+
+
+import com.mybatisfle.test.mybatisflexspringbootseata.entity.OrderTbl;
+import com.mybatisflex.core.BaseMapper;
+
+/**
+ * 映射层。
+ *
+ * @author life
+ * @since 2023-08-03
+ */
+public interface OrderTblMapper extends BaseMapper {
+
+}
diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/mapper/StockTblMapper.java b/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/mapper/StockTblMapper.java
new file mode 100644
index 00000000..ef6abe50
--- /dev/null
+++ b/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/mapper/StockTblMapper.java
@@ -0,0 +1,15 @@
+package com.mybatisfle.test.mybatisflexspringbootseata.mapper;
+
+
+import com.mybatisfle.test.mybatisflexspringbootseata.entity.StockTbl;
+import com.mybatisflex.core.BaseMapper;
+
+/**
+ * 映射层。
+ *
+ * @author life
+ * @since 2023-08-03
+ */
+public interface StockTblMapper extends BaseMapper {
+
+}
diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/service/TestService.java b/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/service/TestService.java
new file mode 100644
index 00000000..b99f4029
--- /dev/null
+++ b/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/service/TestService.java
@@ -0,0 +1,53 @@
+package com.mybatisfle.test.mybatisflexspringbootseata.service;
+
+
+import com.mybatisfle.test.mybatisflexspringbootseata.entity.AccountTbl;
+import com.mybatisfle.test.mybatisflexspringbootseata.entity.OrderTbl;
+import com.mybatisfle.test.mybatisflexspringbootseata.entity.StockTbl;
+import com.mybatisfle.test.mybatisflexspringbootseata.entity.table.AccountTblTableDef;
+import com.mybatisfle.test.mybatisflexspringbootseata.mapper.AccountTblMapper;
+import com.mybatisfle.test.mybatisflexspringbootseata.mapper.OrderTblMapper;
+import com.mybatisfle.test.mybatisflexspringbootseata.mapper.StockTblMapper;
+import com.mybatisflex.core.datasource.DataSourceKey;
+import com.mybatisflex.core.query.QueryWrapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+@Service
+public class TestService {
+
+ @Autowired
+ AccountTblMapper accountTblMapper;
+
+ @Autowired
+ OrderTblMapper orderTblMapper;
+
+ @Autowired
+ StockTblMapper stockTblMapper;
+
+// @Transactional
+ public boolean buy() {
+// DataSourceKey.use("accountdb");
+ QueryWrapper account =new QueryWrapper();
+ account.where(AccountTblTableDef.ACCOUNT_TBL.USER_ID.eq("1001"));
+ AccountTbl accountTbl = accountTblMapper.selectOneByQuery(account);
+ accountTbl.setMoney(accountTbl.getMoney() - 5);
+ accountTblMapper.update(accountTbl);
+// DataSourceKey.use("stockdb");
+// QueryWrapper stock = new QueryWrapper();
+// stock.where("id=1");
+// StockTbl stockTbl = stockTblMapper.selectOneByQuery(stock);
+// stockTbl.setCount(stockTbl.getCount() - 1);
+// stockTblMapper.update(stockTbl);
+// DataSourceKey.use("orderdb");
+// OrderTbl orderTbl = new OrderTbl();
+// orderTbl.setCount(5);
+// orderTbl.setMoney(5);
+// orderTbl.setUserId(accountTbl.getUserId());
+// orderTbl.setCount(1);
+// orderTbl.setCommodityCode(stockTbl.getCommodityCode());
+// orderTblMapper.insert(orderTbl);
+ return true;
+ }
+}
diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/utils/Codegen.java b/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/utils/Codegen.java
new file mode 100644
index 00000000..a1dd2649
--- /dev/null
+++ b/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/java/com/mybatisfle/test/mybatisflexspringbootseata/utils/Codegen.java
@@ -0,0 +1,88 @@
+package com.mybatisfle.test.mybatisflexspringbootseata.utils;
+
+import com.mybatisflex.codegen.Generator;
+import com.mybatisflex.codegen.config.ColumnConfig;
+import com.mybatisflex.codegen.config.GlobalConfig;
+import com.zaxxer.hikari.HikariDataSource;
+
+public class Codegen {
+
+ public static void main(String[] args) {
+ //配置数据源
+ HikariDataSource dataSource = new HikariDataSource();
+ dataSource.setJdbcUrl("jdbc:mysql://127.0.0.1:3306/db_stock?characterEncoding=utf-8");
+ dataSource.setUsername("root");
+ dataSource.setPassword("131496");
+
+ //创建配置内容,两种风格都可以。
+ GlobalConfig globalConfig = createGlobalConfigUseStyle1();
+ //GlobalConfig globalConfig = createGlobalConfigUseStyle2();
+
+ //通过 datasource 和 globalConfig 创建代码生成器
+ Generator generator = new Generator(dataSource, globalConfig);
+
+ //生成代码
+ generator.generate();
+ }
+
+ public static GlobalConfig createGlobalConfigUseStyle1() {
+ //创建配置内容
+ GlobalConfig globalConfig = new GlobalConfig();
+
+ //设置根包
+ globalConfig.setBasePackage("com.mybatisfle.test.mybatisflexspringbootseata");
+
+ //设置表前缀和只生成哪些表
+ globalConfig.setGenerateSchema("db_stock");
+// globalConfig.setTablePrefix("tb_");
+ globalConfig.setGenerateTable("stock_tbl");
+
+ //设置生成 entity 并启用 Lombok
+ globalConfig.setEntityGenerateEnable(true);
+ globalConfig.setEntityWithLombok(true);
+
+ //设置生成 mapper
+ globalConfig.setMapperGenerateEnable(true);
+
+ //可以单独配置某个列
+// ColumnConfig columnConfig = new ColumnConfig();
+// columnConfig.setColumnName("tenant_id");
+// columnConfig.setLarge(true);
+// columnConfig.setVersion(true);
+// globalConfig.setColumnConfig("account", columnConfig);
+
+ return globalConfig;
+ }
+
+ public static GlobalConfig createGlobalConfigUseStyle2() {
+ //创建配置内容
+ GlobalConfig globalConfig = new GlobalConfig();
+
+ //设置根包
+ globalConfig.getPackageConfig()
+ .setBasePackage("com.test");
+
+ //设置表前缀和只生成哪些表,setGenerateTable 未配置时,生成所有表
+ globalConfig.getStrategyConfig()
+ .setGenerateSchema("schema")
+ .setTablePrefix("tb_")
+ .setGenerateTable("account", "account_session");
+
+ //设置生成 entity 并启用 Lombok
+ globalConfig.enableEntity()
+ .setWithLombok(true);
+
+ //设置生成 mapper
+ globalConfig.enableMapper();
+
+ //可以单独配置某个列
+ ColumnConfig columnConfig = new ColumnConfig();
+ columnConfig.setColumnName("tenant_id");
+ columnConfig.setLarge(true);
+ columnConfig.setVersion(true);
+ globalConfig.getStrategyConfig()
+ .setColumnConfig("account", columnConfig);
+
+ return globalConfig;
+ }
+}
diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/resources/application.yml b/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/resources/application.yml
new file mode 100644
index 00000000..97c7b42c
--- /dev/null
+++ b/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/resources/application.yml
@@ -0,0 +1,74 @@
+mybatis-flex:
+ seata-config:
+ enable: true #启动seata
+ seata-mode: XA #xa或者ta
+ datasource:
+ accountdb:
+ url: jdbc:mysql://127.0.0.1:3306/db_account
+ username: root
+ password: 131496
+ orderdb:
+ url: jdbc:mysql://127.0.0.1:3306/db_order
+ username: root
+ password: 131496
+ stockdb:
+ url: jdbc:mysql://127.0.0.1:3306/db_stock
+ username: root
+ password: 131496
+server:
+ port: 2010
+seata:
+ enabled: true
+ application-id: business-service
+ tx-service-group: my_test_tx_group
+ enable-auto-data-source-proxy: false #必须
+# use-jdk-proxy: false
+ client:
+ rm:
+ async-commit-buffer-limit: 1000
+ report-retry-count: 5
+ table-meta-check-enable: false
+ report-success-enable: false
+ lock:
+ retry-interval: 10
+ retry-times: 30
+ retry-policy-branch-rollback-on-conflict: true
+ tm:
+ commit-retry-count: 5
+ rollback-retry-count: 5
+ undo:
+ data-validation: true
+ log-serialization: jackson
+ log-table: undo_log
+ log:
+ exceptionRate: 100
+ service:
+ vgroup-mapping:
+ my_test_tx_group: default
+ grouplist:
+ default: 127.0.0.1:8091
+ #enable-degrade: false
+ #disable-global-transaction: false
+ transport:
+ shutdown:
+ wait: 3
+ thread-factory:
+ boss-thread-prefix: NettyBoss
+ worker-thread-prefix: NettyServerNIOWorker
+ server-executor-thread-prefix: NettyServerBizHandler
+ share-boss-worker: false
+ client-selector-thread-prefix: NettyClientSelector
+ client-selector-thread-size: 1
+ client-worker-thread-prefix: NettyClientWorkerThread
+ worker-thread-size: default
+ boss-thread-size: 1
+ type: TCP
+ server: NIO
+ heartbeat: true
+ serialization: seata
+ compressor: none
+ enable-client-batch-send-request: true
+ config:
+ type: file
+ registry:
+ type: file
diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/resources/db/all_in_one.sql b/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/resources/db/all_in_one.sql
new file mode 100644
index 00000000..e4a1f88e
--- /dev/null
+++ b/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/main/resources/db/all_in_one.sql
@@ -0,0 +1,97 @@
+# Account
+DROP SCHEMA IF EXISTS db_account;
+CREATE SCHEMA db_account;
+USE db_account;
+
+CREATE TABLE `account_tbl`
+(
+ `id` INT(11) NOT NULL AUTO_INCREMENT,
+ `user_id` VARCHAR(255) DEFAULT NULL,
+ `money` INT(11) DEFAULT 0,
+ PRIMARY KEY (`id`)
+) ENGINE = InnoDB
+ DEFAULT CHARSET = utf8;
+
+INSERT INTO account_tbl (id, user_id, money)
+VALUES (1, '1001', 10000);
+INSERT INTO account_tbl (id, user_id, money)
+VALUES (2, '1002', 10000);
+
+CREATE TABLE `undo_log`
+(
+ `id` bigint(20) NOT NULL AUTO_INCREMENT,
+ `branch_id` bigint(20) NOT NULL,
+ `xid` varchar(100) NOT NULL,
+ `context` varchar(128) NOT NULL,
+ `rollback_info` longblob NOT NULL,
+ `log_status` int(11) NOT NULL,
+ `log_created` datetime NOT NULL,
+ `log_modified` datetime NOT NULL,
+ `ext` varchar(100) DEFAULT NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `ux_undo_log` (`xid`,`branch_id`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
+
+# Order
+DROP SCHEMA IF EXISTS db_order;
+CREATE SCHEMA db_order;
+USE db_order;
+
+CREATE TABLE `order_tbl`
+(
+ `id` INT(11) NOT NULL AUTO_INCREMENT,
+ `user_id` VARCHAR(255) DEFAULT NULL,
+ `commodity_code` VARCHAR(255) DEFAULT NULL,
+ `count` INT(11) DEFAULT '0',
+ `money` INT(11) DEFAULT '0',
+ PRIMARY KEY (`id`)
+) ENGINE = InnoDB
+ DEFAULT CHARSET = utf8;
+
+CREATE TABLE `undo_log`
+(
+ `id` bigint(20) NOT NULL AUTO_INCREMENT,
+ `branch_id` bigint(20) NOT NULL,
+ `xid` varchar(100) NOT NULL,
+ `context` varchar(128) NOT NULL,
+ `rollback_info` longblob NOT NULL,
+ `log_status` int(11) NOT NULL,
+ `log_created` datetime NOT NULL,
+ `log_modified` datetime NOT NULL,
+ `ext` varchar(100) DEFAULT NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `ux_undo_log` (`xid`,`branch_id`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
+
+# stock
+DROP SCHEMA IF EXISTS db_stock;
+CREATE SCHEMA db_stock;
+USE db_stock;
+
+CREATE TABLE `stock_tbl`
+(
+ `id` INT(11) NOT NULL AUTO_INCREMENT,
+ `commodity_code` VARCHAR(255) DEFAULT NULL,
+ `count` INT(11) DEFAULT '0',
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `commodity_code` (`commodity_code`)
+) ENGINE = InnoDB
+ DEFAULT CHARSET = utf8;
+
+
+INSERT INTO stock_tbl (id, commodity_code, count)
+VALUES (1, '2001', 1000);
+
+CREATE TABLE `undo_log`
+(
+ `id` bigint(20) NOT NULL AUTO_INCREMENT,
+ `branch_id` bigint(20) NOT NULL,
+ `xid` varchar(100) NOT NULL,
+ `context` varchar(128) NOT NULL,
+ `rollback_info` longblob NOT NULL,
+ `log_status` int(11) NOT NULL,
+ `log_created` datetime NOT NULL,
+ `log_modified` datetime NOT NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `ux_undo_log` (`xid`,`branch_id`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/test/java/com/mybatisfle/test/mybatisflexspringbootseata/MybatisFlexSpringBootSeataApplicationTests.java b/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/test/java/com/mybatisfle/test/mybatisflexspringbootseata/MybatisFlexSpringBootSeataApplicationTests.java
new file mode 100644
index 00000000..f763ac31
--- /dev/null
+++ b/mybatis-flex-test/mybatis-flex-spring-boot-seata/src/test/java/com/mybatisfle/test/mybatisflexspringbootseata/MybatisFlexSpringBootSeataApplicationTests.java
@@ -0,0 +1,13 @@
+package com.mybatisfle.test.mybatisflexspringbootseata;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+class MybatisFlexSpringBootSeataApplicationTests {
+
+ @Test
+ void contextLoads() {
+ }
+
+}
diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/resources/application.yml b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/resources/application.yml
index 36c7ddb6..4dca4a42 100644
--- a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/resources/application.yml
+++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/resources/application.yml
@@ -3,11 +3,11 @@ spring:
# h2:
# console:
# enabled: true
- datasource:
-# driver-class-name: com.mysql.cj.jdbc.Driver
- url: jdbc:mysql://localhost:3306/flex_test
- username: root
- password: 123456
+# datasource:
+## driver-class-name: com.mysql.cj.jdbc.Driver
+# url: jdbc:mysql://localhost:3306/flex_test
+# username: root
+# password: 131496
# driver-class-name:
# datasource:
# driver-class-name: org.h2.Driver
@@ -37,12 +37,12 @@ mybatis-flex:
# username: root
# password: 12345678
#mybatis-flex:
-# datasource:
-# ds1:
-# url: jdbc:mysql://127.0.0.1:3306/db
-# username: root
-# password: 123456
-# ds2:
-# url: jdbc:mysql://127.0.0.1:3306/db2
-# username: root
-# password: 123456
+ datasource:
+ ds3333:
+ url: jdbc:mysql://127.0.0.1:3306/flex_test
+ username: root
+ password: 131496
+ ds2:
+ url: jdbc:mysql://127.0.0.1:3306/flex_test1
+ username: root
+ password: 131496
diff --git a/mybatis-flex-test/pom.xml b/mybatis-flex-test/pom.xml
index c1a4a577..de11100a 100644
--- a/mybatis-flex-test/pom.xml
+++ b/mybatis-flex-test/pom.xml
@@ -18,6 +18,7 @@
mybatis-flex-spring-test
mybatis-flex-spring-boot-test
mybatis-flex-spring-cloud-test
+ mybatis-flex-spring-boot-seata