springclould seata nacos feign集成
版本:
<springboot.version>2.3.6.RELEASE</springboot.version>
<springclould.version>Hoxton.SR9</springclould.version>
<springcloud.alibaba.version>2.2.3.RELEASE</springcloud.alibaba.version>
<seata.version>1.4.0</seata.version>
服务配置:application.yml
server:
port: 8081
spring:
datasource:
username: root
password: yhj19950715
url: jdbc:mysql://192.168.176.1/senta?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
application:
name: server1
cloud:
nacos:
discovery:
server-addr : 127.0.0.1:8848
seata:
enabled: true
application-id: ${spring.application.name}
enable-auto-data-source-proxy: true
tx-service-group: SEATA_GROUP
service:
vgroupMapping:
SEATA_GROUP: default 需要在nacos配置中心中增加对应的事务分组配置项,或者将此处事务分组名使用nacos.config 中 配置的默认配置项
config:
type: nacos
nacos:
server-addr: 127.0.0.1:8848
group : "SEATA_GROUP"
namespace: ""
username: "nacos"
password: "nacos"
registry:
type: nacos
nacos:
server-addr: 127.0.0.1:8848
namespace: ""
group: SEATA_GROUP
cluster: default
application: seata-server
注意点:
class: io.seata.discovery.registry.RegistryService
default String getServiceGroup(String key) {
key = PREFIX_SERVICE_ROOT + CONFIG_SPLIT_CHAR + PREFIX_SERVICE_MAPPING + key;
if (!SERVICE_GROUP_NAME.contains(key)) {
ConfigurationCache.addConfigListener(key);
SERVICE_GROUP_NAME.add(key);
}
return ConfigurationFactory.getInstance().getConfig(key);
}
PREFIX_SERVICE_ROOT: service
CONFIG_SPLIT_CHAR: .
PREFIX_SERVICE_MAPPING: vgroupMapping.
通过此处就可以生成一个key 而后将会根据此key*在nacos中寻找服务
*
详情见:http://seata.io/zh-cn/docs/user/txgroup/transaction-group.html
搭建的其他部分见引用:
https://blog.csdn.net/weixin_45481406/article/details/114763504