seata和postgresql和springcloud整合

第一步导入坐标

 <dependency>
        <groupId>org.postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <scope>runtime</scope>
    </dependency>

    <!--druid-->
    <dependency>
        <groupId>com.alibaba</groupId>
        <artifactId>druid-spring-boot-starter</artifactId>
        <version>1.1.10</version>
    </dependency>

    <!-- mp 依赖 -->
    <dependency>
        <groupId>com.baomidou</groupId>
        <artifactId>mybatis-plus-boot-starter</artifactId>
        <version>3.2.0</version>
    </dependency>


    <dependency>
        <groupId>com.alibaba.cloud</groupId>
        <artifactId>spring-cloud-alibaba-seata</artifactId>
        <version>2.2.0.RELEASE</version>
        <exclusions>
            <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.3.0</version>
    </dependency>

第二步增加seata配置

seata:
  enabled: true
  application-id: demo
  tx-service-group: my_test_tx_group
  enable-auto-data-source-proxy: true
  config:
    type: nacos
    nacos:
      namespace:
      server-addr: 192.168.101.50:8848
      group: SEATA_GROUP
      username: nacos
      password: nacos
  registry:
    type: nacos
    nacos:
      application: seata-server
      server-addr: 192.168.101.50:8848
      namespace:
      username: nacos
      password: nacos

第三步resources下增加seata.conf文件

## ---------------------------------------------------------------------------
## Licensed to the Apache Software Foundation (ASF) under one or more
## contributor license agreements.  See the NOTICE file distributed with
## this work for additional information regarding copyright ownership.
## The ASF licenses this file to You under the Apache License, Version 2.0
## (the "License"); you may not use this file except in compliance with
## the License.  You may obtain a copy of the License at
##
##      http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
## ---------------------------------------------------------------------------

client {
    ##这是唯一的和项目名保持一致
    application.id = demo
    transaction.service.group = my_test_tx_group
}
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在ata1.4.2中,整合springcloud2021.1的步骤如下: 1. 首先,确保你已经正确安装并配置了Spring Cloud和Seata的依赖。根据引用提供的信息,你需要使用springcloud 2021.0.1版本和seata 1.4.2版本。 2. 在你的Spring Boot项目中,添加Seata和Spring Cloud的相关依赖。这包括seata-spring-boot-starter和spring-cloud-dependencies等。 3. 在你的配置文件中,配置Seata和Spring Cloud的相关配置。例如,配置Seata的事务组名称、事务日志存储模式等。同时,你还需要配置Spring Cloud的注册中心、服务发现等相关配置。 4. 在你的业务代码中,使用Seata的分布式事务注解对需要进行事务管理的方法进行标注。这可以确保在分布式环境中,使用Seata进行事务管理。 5. 最后,通过Feign进行远程调用。根据你提供的信息,你可以使用Feign来实现订单和库存之间的远程调用。通过Feign的注解和配置,你可以定义需要调用的服务接口,并在业务代码中进行调用。 总结一下,整合seata1.4.2和springcloud2021.1的步骤包括添加依赖、配置相关信息、使用Seata进行事务管理和通过Feign进行远程调用。希望这些步骤对你有帮助。<span class="em">1</span> #### 引用[.reference_title] - *1* [最新版本SpringCloud+seata+nacos实现全局事物处理的demo案例](https://download.csdn.net/download/m0_55710969/85082794)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值