ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

springcloud整合seata实现分布式事务(三)

2020-11-28 14:01:01  阅读:293  来源: 互联网

标签:group seata springcloud server application registry conf 分布式


描述:

前面两篇文章已经讲完怎么启动项目了,现在,主要讲项目启动的时候,代码的寻找逻辑,注意,这是重点,官网的描述有些问题,我在采坑后才分享的。

坑一:,seata-server的版本问题

我在下载seata 0.7.0的时候,还有点开里面的file-conf,还有vgroup_mapping的配置,可是,到了1.4.0的时候,已经没有了,

官网的配置地址为:https://github.com/seata/seata-samples/tree/master/springcloud-eureka-feign-mybatis-seata 说明,这个文档对应的数据版本有点老了,

在折腾了一番后,知道了,1.4.0不用配置! , 他对应的group的名字,就是registry.conf,里面的application-name,也就是seata-server注册到注册中心的那个名字,

就是group的名字!

坑二:关于accout-server,order-server,storage-server里面的配置文件对应关系问题

我们主要关注3个文件:file.conf,registry.conf,application.yml

怎么改:

一:application,yml里面的

spring:
    application:
        name: order-server    --order-server这个名字,对应的是 registry.conf里面的application-name=order-server
    cloud:
        alibaba:
            seata:
                tx-service-group: fsp_tx_group    -fsp_tx_group-这个名字,对应的是file.conf里面的vgroupMapping.fsp_tx_group

 

二:file.conf
service {
  #transaction service group mapping
  vgroupMapping.fsp_tx_group = "seata-server"            --seata-server这个名字,对应的是seata 1.4.0这个服务注册到服务注册中心的名字,在seata 1.4.0的registry.conf里面的application-name里面有配置
  #only support when registry.type=file, please don't set multiple addresses
  default.grouplist = "127.0.0.1:8091"
  #degrade, current not support
  enableDegrade = false
  #disable seata
  disableGlobalTransaction = false
}
三:registry.conf
registry {
  # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
  type = "eureka"

  nacos {
    serverAddr = "localhost"
    namespace = ""
    cluster = "default"
  }
  eureka {
    serviceUrl = "http://localhost:8761/eureka"
    application = "order-server"  --对应在application.yml配置的application-name
    weight = "1"
  }

}

三:关于假如从官网下载下来的代码,会有的问题:

一:mysql的版本问题,导致报错,找不到数据库

二:使用的项目版本问题,主要采用2020年相对比较新,且稳定的版本

我在网盘中的项目相关版本为:

springboot :2.2.5

springcloud:Hoxton.SR8

msyql:8.0.19

seata:1.4.0

spring-cloud-alibaba-seata: 2.1.1

标签:group,seata,springcloud,server,application,registry,conf,分布式
来源: https://blog.csdn.net/qq_34790227/article/details/110266314

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有