文章目录
- 1、解压 seata-server-1.7.1.zip
- 2、启动 双击 seata-server.bat
- 3、启动 seata 控制台用户界面
- 4、所有分布式事务相关数据库要有undo-log
- 5、项目引入seata依赖
- 6、项目添加seata配置
- 7、代码实现:
1、解压 seata-server-1.7.1.zip
2、启动 双击 seata-server.bat
Active code page: 65001
"E:\seata-server-1.7.1\seata/logs"
"apm-skywalking not enabled"
[0.042s][warning][gc] -Xloggc is deprecated. Will use -Xlog:gc:E:\seata-server-1.7.1\seata/logs/seata_gc.log instead.
[0.048s][info ][gc] Using G1
[2.012s][info ][gc] GC(0) Pause Young (Normal) (G1 Evacuation Pause) 102M->12M(2048M) 7.485ms
███████╗███████╗ █████╗ ████████╗ █████╗
██╔════╝██╔════╝██╔══██╗╚══██╔══╝██╔══██╗
███████╗█████╗ ███████║ ██║ ███████║
╚════██║██╔══╝ ██╔══██║ ██║ ██╔══██║
███████║███████╗██║ ██║ ██║ ██║ ██║
╚══════╝╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝19:02:02.543 INFO --- [ main] [ta.config.ConfigurationFactory] [ load] [] : load Configuration from :Spring Configuration
19:02:02.579 INFO --- [ main] [ta.config.ConfigurationFactory] [ buildConfiguration] [] : load Configuration from :Spring Configuration
19:02:02.607 INFO --- [ main] [seata.server.ServerApplication] [ logStarting] [] : Starting ServerApplication v1.7.1 using Java 17 on DESKTOP-JRQ5NMD with PID 18200 (E:\seata-server-1.7.1\seata\target\seata-server.jar started by dgq in E:\seata-server-1.7.1\seata\bin)
19:02:02.608 INFO --- [ main] [seata.server.ServerApplication] [ogStartupProfileInfo] [] : No active profile set, falling back to 1 default profile: "default"
[2.735s][info ][gc] GC(1) Pause Young (Normal) (G1 Evacuation Pause) 103M->15M(2048M) 7.046ms
[3.947s][info ][gc] GC(2) Pause Young (Normal) (G1 Evacuation Pause) 125M->18M(2048M) 5.283ms
19:02:04.685 INFO --- [ main] [mbedded.tomcat.TomcatWebServer] [ initialize] [] : Tomcat initialized with port(s): 7091 (http)
19:02:04.698 INFO --- [ main] [oyote.http11.Http11NioProtocol] [ log] [] : Initializing ProtocolHandler ["http-nio-7091"]
19:02:04.698 INFO --- [ main] [.catalina.core.StandardService] [ log] [] : Starting service [Tomcat]
19:02:04.700 INFO --- [ main] [e.catalina.core.StandardEngine] [ log] [] : Starting Servlet engine: [Apache Tomcat/9.0.62]
19:02:04.797 INFO --- [ main] [rBase.[Tomcat].[localhost].[/]] [ log] [] : Initializing Spring embedded WebApplicationContext
19:02:04.797 INFO --- [ main] [letWebServerApplicationContext] [ebApplicationContext] [] : Root WebApplicationContext: initialization completed in 2129 ms
19:02:05.445 INFO --- [ main] [vlet.WelcomePageHandlerMapping] [ <init>] [] : Adding welcome page: class path resource [static/index.html]
19:02:05.745 INFO --- [ main] [oyote.http11.Http11NioProtocol] [ log] [] : Starting ProtocolHandler ["http-nio-7091"]
19:02:05.782 INFO --- [ main] [mbedded.tomcat.TomcatWebServer] [ start] [] : Tomcat started on port(s): 7091 (http) with context path ''
19:02:05.797 INFO --- [ main] [seata.server.ServerApplication] [ logStarted] [] : Started ServerApplication in 4.46 seconds (JVM running for 5.421)
19:02:06.087 INFO --- [ main] [a.server.session.SessionHolder] [ init] [] : use session store mode: file
19:02:06.103 INFO --- [ main] [rver.lock.LockerManagerFactory] [ init] [] : use lock store mode: file
19:02:06.289 INFO --- [ main] [rpc.netty.NettyServerBootstrap] [ start] [] : Server started, service listen port: 8091
19:02:06.303 INFO --- [ main] [io.seata.server.ServerRunner ] [ run] [] :you can visit seata console UI on http://127.0.0.1:7091.log path: C:\Users\dgq/logs/seata.
19:02:06.303 INFO --- [ main] [io.seata.server.ServerRunner ] [ run] [] : seata server started in 503 millSeconds
3、启动 seata 控制台用户界面
you can visit seata console UI on http://127.0.0.1:7091
4、所有分布式事务相关数据库要有undo-log
seata快速开始:https://seata.apache.org/zh-cn/docs/user/quickstart/
CREATE TABLE IF NOT EXISTS `undo_log`
(`branch_id` BIGINT NOT NULL COMMENT 'branch transaction id',`xid` VARCHAR(128) NOT NULL COMMENT 'global transaction id',`context` VARCHAR(128) NOT NULL COMMENT 'undo_log context,such as serialization',`rollback_info` LONGBLOB NOT NULL COMMENT 'rollback info',`log_status` INT(11) NOT NULL COMMENT '0:normal status,1:defense status',`log_created` DATETIME(6) NOT NULL COMMENT 'create datetime',`log_modified` DATETIME(6) NOT NULL COMMENT 'modify datetime',UNIQUE KEY `ux_undo_log` (`xid`, `branch_id`)) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8mb4 COMMENT ='AT transaction mode undo table';
ALTER TABLE `undo_log` ADD INDEX `ix_log_created` (`log_created`);
5、项目引入seata依赖
<dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-seata</artifactId></dependency><dependency><groupId>io.seata</groupId><artifactId>seata-spring-boot-starter</artifactId></dependency>
6、项目添加seata配置
seata: tx-service-group: guli_tx_groupservice:vgroup-mapping:guli_tx_group: defaultgrouplist:default: localhost:8091