尚硅谷周阳老师的视频地址(147集左右):尚硅谷SpringCloud框架开发教程(SpringCloudAlibaba微服务分布式架构丨Spring Cloud)_哔哩哔哩_bilibili制作不易,大家记得点个关注,一键三连呀【点赞、投币、收藏】感谢支持~尚硅谷SpringCloud 1 视频,一经推出,广受好评。本视频含SpringCloud Hoxton和SpringCloud alibaba,双剑合并,威力大增!内容涵盖目前火热的分布式微服务架构的全部技术栈,是尚硅谷高阶班微服务课程的全新升级版。新版教程对老版的五大技术做了升级加强和替换更新,对原有技术进行了更加深入的讲解


https://www.bilibili.com/video/BV18E411x7eT?p=147

周阳老师用的seta-0.9.0 版本 ,如何改成 1.4.2版本,请参考如下链接:

Seata1.4.2+Nacos搭建使用_ww_run的博客-CSDN博客Seata1.4.2+Nacos搭建使用前言一、搭建seata1.4.2服务端1.下载seata1.4.22.创建相关数据库和表3.配置Seata 1.4.24.启动seata1.4.2二、客户端使用seata1.4.21.准备工作2.测试seata1.4.23.测试结果前言[seata官网](https://seata.io/zh-cn/) 搭建环境: windows10 AlibabaSpringcloud版本: 2.1.3.RELEASE 数据库mysql.5.7.+一、搭建se注意事项(重要): 1.下载的时候,seata 源码包和seata-server 都下载,下载2个。

源码包和服务端server的包,csdn上的下载地址:seata-1.4.2.rar-Java文档类资源-CSDN下载 2.需要把 源码包的  script/config-center/config.txt  配置到nacos,就是 新增 nacos配置。 3.建senta的mysql数据库的脚本在 源码包的script\server\db\mysql.sql

4.pom.xml 文件里中 seata的配置。

<dependency>
    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-starter-alibaba-seata</artifactId>
    <exclusions>
        <!-- 要与seata服务端版本一直,所以把自带的替换掉 -->
        <exclusion>
            <groupId>io.seata</groupId>
            <artifactId>seata-spring-boot-starter</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>io.seata</groupId>
    <artifactId>seata-spring-boot-starter</artifactId>
    <version>1.4.2</version>
</dependency>

5.yml文件,配置文件的编写。(seata 应该定格写,不在sping 下面了。不需要添加server/config/file.conf  和registry.conf )

seata:
  enabled: true
  enable-auto-data-source-proxy: true #是否开启数据源自动代理,默认为true
  tx-service-group: my_test_tx_group  #要与配置文件中的vgroupMapping一致
  registry:  #registry根据seata服务端的registry配置
    type: nacos #默认为file
    nacos:
      application: seata-server #配置自己的seata服务
      server-addr: localhost:8848 #根据自己的seata服务配置
      username: nacos
      password: nacos
      namespace: 2b44d27c-91ed-4742-9597-2a726cf635ab  # seata-server在nacos的命名空间ID
      cluster: default # 配置自己的seata服务cluster, 默认为 default
      group: SEATA_GROUP    # seata-server在nacos的分组
  config:
    type: nacos #默认file,如果使用file不配置下面的nacos,直接配置seata.service
    nacos:
      server-addr: localhost:8848 #配置自己的nacos地址
      group: SEATA_GROUP #配置自己的dev
      username: nacos
      password: nacos
      namespace: 2b44d27c-91ed-4742-9597-2a726cf635ab
      dataId: seataServer.properties   #配置自己的dataId,由于搭建服务端时把客户端的配置也写在了seataServer.properties,所以这里用了和服务端一样的配置文件,实际客户端和服务端的配置文件分离出来更好

  6.启动类上添加注解 @EnableAutoDataSourceProxy。特别注意:删除原来的config/DataSourceProxyConfig.java7.每个涉及到整个事务管理的微服务,都要添加 seata的配置。