av激情亚洲男人的天堂国语,日韩欧美精品一中文字幕,无码av一区二区三区无码,国产又色又爽又刺激的a片,国产又色又爽又刺激的a片

Seata多數(shù)據(jù)源如何代理?

Seata多數(shù)據(jù)源代理通過配置數(shù)據(jù)源路由規(guī)則,實現(xiàn)分布式事務(wù)的提交和回滾,確保數(shù)據(jù)的一致性。

Seata多數(shù)據(jù)源代理是指在分布式系統(tǒng)中,通過Seata實現(xiàn)多個數(shù)據(jù)源之間的事務(wù)管理,下面將詳細(xì)介紹Seata多數(shù)據(jù)源代理的步驟和配置方法。

1、引入Seata依賴

在項目的pom.xml文件中添加Seata的依賴:


    io.seata
    seataall
    最新版本號

2、配置數(shù)據(jù)源

在Spring配置文件中配置多個數(shù)據(jù)源,例如application.yml:

spring:
  datasource:
    primary:
      url: jdbc:mysql://localhost:3306/db1?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8
      username: root
      password: 123456
      driverclassname: com.mysql.cj.jdbc.Driver
    secondary:
      url: jdbc:mysql://localhost:3306/db2?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8
      username: root
      password: 123456
      driverclassname: com.mysql.cj.jdbc.Driver

3、配置Seata事務(wù)管理器

在Spring配置文件中配置Seata事務(wù)管理器,例如application.yml:

spring:
  cloud:
    alibaba:
      seata:
        txservicegroup: my_test_tx_group

txservicegroup是事務(wù)組名,可以根據(jù)實際情況進(jìn)行修改。

4、創(chuàng)建Seata事務(wù)注解類

創(chuàng)建一個Seata事務(wù)注解類,用于標(biāo)記需要進(jìn)行事務(wù)管理的方法,

import io.seata.annotation.GlobalTransactional;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
public class MyService {
    @GlobalTransactional // 開啟全局事務(wù),使用Seata進(jìn)行事務(wù)管理
    @Transactional // 聲明當(dāng)前方法是本地事務(wù),使用Spring進(jìn)行事務(wù)管理
    public void doSomething() {
        // 業(yè)務(wù)邏輯代碼...
    }
}

在需要使用Seata進(jìn)行事務(wù)管理的方法上添加@GlobalTransactional注解,同時也可以添加@Transactional注解來聲明本地事務(wù)。

5、配置Seata服務(wù)器端信息

在Seata的配置文件中配置服務(wù)器端信息,例如seataserver.conf:

seata服務(wù)器地址和端口號,根據(jù)實際情況進(jìn)行修改
server.port=8091
數(shù)據(jù)庫連接信息,根據(jù)實際情況進(jìn)行修改
spring.datasource.druid.url=jdbc:mysql://localhost:3306/seata?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC&zeroDateTimeCreationDatetimeModeInsensitiveEqualsFilterEnabledZeroDateTimeBehaviorAllowNonExistingValueAllowSubsecondPrecisionAllowLegacyDatetimeStringRepresentationUseAffectedRowsOptimizerDisableNamedParameterJdbcTemplateCacheStrictSqlSessionFactoryLeakExceptionHandlerDisableAutoCommitFalseMaxPoolSize100MinPoolSize8ConnectionTimeout3000QueryTimeout60000TestOnBorrowReturnConnectionOnCheckoutCloseConnectionAfterUsageStatementNotClosedByCompletionResultSetHoldabilityDefaultFetchSize0MaxFetchSizeIntegerTypeHandlerRegistrySupportsGetGeneratedKeysBatchUpdateSizeIntegerBatchSizeForSelectMultiplierSingleSelectLoadBalancerRoundRobinRandomWeightLocalTransactionScopeStatelessSupportsTransactionsNestedPropagationRequiredNewFixedThreadPoolSize100不啟用查詢緩存select * from tableName where id = 'xxx'; # 查詢語句,根據(jù)實際情況進(jìn)行修改

文章標(biāo)題:Seata多數(shù)據(jù)源如何代理?
URL標(biāo)題:http://uogjgqi.cn/article/djgpshg.html
掃二維碼與項目經(jīng)理溝通

我們在微信上24小時期待你的聲音

解答本文疑問/技術(shù)咨詢/運(yùn)營咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流