Fork me on GitHub

SEATA 1.0.0使用yaml配置替换file.conf 和 registry.conf

Client Configure for SEATA 1.0.0

在SEATA 1.0.0 中发布了一个新的feature,可以使用yaml/properties来替换掉我们在之前引入的file.confregistry.conf. 只需2步即可达到目的:

  • 第一步,更改依赖

    <!--seata-->
            <dependency>
                <groupId>io.seata</groupId>
                <artifactId>seata-spring-boot-starter</artifactId>
                <version>1.0.0</version>
                <exclusions>
                    <exclusion>
                        <artifactId>seata-all</artifactId>
                        <groupId>io.seata</groupId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>io.seata</groupId>
                <artifactId>seata-all</artifactId>
                <version>1.0.0</version>
            </dependency>
    

    官方的说法是只需要依赖seata-spring-boot-starter即可,但是在实际的过程中,该依赖内部依然使用的是seata-all 0.9版本,会报错,因此我单独引入了seata-all 1.0.0,提交 github issue,

  • 第二步:修改配置

server:
  port: 8001
# 1.0新添加的enabled激活自动配置,使得我们可以在yaml/properties文件中配置,
# 避免了以前需要客户端引入2个文件:
# file.conf 和 registry.conf
seata:
  enabled: true # 1.0新特性,需要依赖seata-spring-boot-starter,默认为true
  tx-service-group: geekplus_tx_group
#  transport:
#    type: TCP #default value is TCP
#    server: NIO #default value is NIO
#    heartbeat: true #enable heartbeat
#    enable-client-batch-send-request: true
#    serialization: seata
#    compressor: none
#    shutdown:
#      wait: 3 #when destroy server, wait seconds
  registry:
    type: eureka
    eureka:
      service-url: http://localhost:8888/eureka
#      application: default
#      weight: 1
#  service:
#    vgroup-mapping: geekplus_tx_group
#    disable-global-transaction: false
#    disableGlobalTransaction: false
  client:
    support:
      spring:
        datasource-autoproxy: false
spring:
  application:
    name: seata-1-0-transaction
...

你可以在spring-configuration-metadata.json文件中找到相对应的配置属性. 在使用service属性时,同样存在1个问题,关于disableGlobalTransactiondisable-global-transaction都无法生效的问题。Git issue.
详情演示可查看demo/mscx-seata-1-0-demo

posted @ 2020-01-16 14:25  IsaacZhang  阅读(3666)  评论(0编辑  收藏  举报