注解使用方式需要在GTS客户端上部署SDK,才能使用分布式事务。GTS SDK目前只支持Java版本。
               
                  操作步骤
                  
                     - 下载GTS SDK开发包。
                           建议选择GTS SDK最新版本,也可以根据实际需求选择其它历史版本,详情请参见版本说明。
                           
                         
                      
                     - 可选:如果需要Spring Cloud原生支持,需要下载Spring Cloud原生支持包,更多内容,请参见原生 Spring Cloud 应用样例。
                           
                              
                              说明 若之前从未使用过
GTS
或者
Seata,建议使用
2.8.x
版本;若想兼容支持开源
Seata
的功能,请在版本列表选择
2.9.x
的版本,若想添加
Spring Cloud
的支持,需要额外配置
spring-cloud-alibaba-seata。目前
Seata
已支持多种数据库,多种
RPC
框架,详情请参见
                                 
Seata。
                              
 
                            
                         
                      
                     - 将GTS SDK开发包上传到GTS客户端所在的机器上。
 
                     - 将SDK开发包添加到应用的依赖中。
                           具体方式没有限制,这里不一一列举。
                           典型的情况是:如果使用Maven来管理应用工程,可以将SDK开发包添加到pom.xml依赖中。
                           
                           将SDK开发包添加到pom.xml依赖中的示例如下:
                           
<dependency>
    <groupId>com.taobao.txc</groupId>
    <artifactId>txc-client</artifactId>
    <version>${txc-version}</version>
    <scope>system</scope>
    <systemPath>SDK的存放路径</systemPath>
</dependency>
使用Spring Cloud原生支持时,如果应用中自己定义了WebMvcConfigurationSupport,请添加 TxcInboundHander的实例,示例代码如下:
                           
public class MyWebMvcConfigurationSupport extends WebMvcConfigurationSupport {
    @Override
    protected void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new TxcInboundHandler()).addPathPatterns(new String[] { "/**" });
    }
}