author:zxw
email:502513206@qq.com
@ Jishou University
最近在学习seata框架的使用,但是花了很久时间才把项目搭起来,主要是第一次使用要踩挺多坑的。比如在我们的业务项目要在resource目录下添加file.config和registry.conf两个配置文件,作为第一次使用的萌新确实很难发现,官网上也没有详细的教程,还有一个最主要的错误就是
Could not found property service.vgroup_mapping.my_test_tx_group, try to use default value instead.
这个问题处理了很久,终于是搞定并且能够让项目启动了,接下来就看看怎么解决这个问题。
首先从官网上下载seata服务端的程序包到本地,然后打开里面的config目录,发现有以下几个文件
registry:可以在里面指定我们的注册中心和配置中心,这边使用的是eureka,所以只需指定注册中心,配置中心就用默认的config就行
registry { type = "eureka" eureka { serviceUrl = "http://localhost:10010/eureka" application = "SEATA" weight = "1" } }然后就是我们的file.config文件了,把下面这块拷进file.conf文件中
service { #transaction service group mapping ## 指定group名 vgroup_mapping.my_test_tx_group = "SEATA" #only support when registry.type=file, please don't set multiple addresses default.grouplist = "10.0.4.23:8091" #disable seata disableGlobalTransaction = false }这边比较要注意的就是vgroup_mapping.my_test_tx_group = "SEATA"这行了,要指定好my_test_tx_group和后面的值,我们的服务代码配置也要跟这里对上。
下面贴下服务代码的配置文件
service { #transaction service group mapping vgroup_mapping.my_test_tx_group = "SEATA" # 这里要注意和我们服务端的seata对应 #only support when registry.type=file, please don't set multiple addresses default.grouplist = "xx.x.x.xx:8091" #degrade, current not support enableDegrade = false #disable seata disableGlobalTransaction = false }最后搞半天就是服务代码的配置文件没和seata服务端对上,这里对上后就能正常启动不在报错了。