• springcloud alibaba 集成seata1.3


    下面只写出我的正确运行的集成环境,

    1、版本要正确,不然报的错你都不知道为什么

    <dependencyManagement>
    <dependencies>
    <!-- 导入Spring Cloud的依赖管理 -->
    <dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-dependencies</artifactId>
    <version>Hoxton.SR8</version>
    <type>pom</type>
    <scope>import</scope>
    </dependency>
    <dependency>
    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-alibaba-dependencies</artifactId>
    <version>2.2.4.RELEASE</version>
    <type>pom</type>
    <scope>import</scope>
    </dependency>
    </dependencies>
    </dependencyManagement>

    2、集成seata

    <!--seata-->
    <dependency>
    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-starter-alibaba-seata</artifactId>
    <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>

    3、代理数据源

    @Configuration
    public class DataSourceConfiguration {


    @Value("${mybatis-plus.mapper-locations}")
    private String mapperLocations;

    @Bean
    @ConfigurationProperties(prefix = "spring.datasource")
    public DataSource druidDataSource(){
    return new DruidDataSource();
    }

    @Bean
    public DataSourceProxy dataSourceProxy(DataSource dataSource) {
    return new DataSourceProxy(dataSource);
    }

    @Bean(name = "TCTransactionManager")
    public DataSourceTransactionManager transactionManager(@Autowired DruidDataSource dataSource) {
    return new DataSourceTransactionManager(dataSource);
    }

    @Bean
    public SqlSessionFactory sqlSessionFactoryBean(DataSourceProxy dataSourceProxy) throws Exception {
    MybatisSqlSessionFactoryBean sqlSessionFactoryBean = new MybatisSqlSessionFactoryBean (); //这里用到了mybatis-plus,如果只是mybaits就用SqlSessionFactoryBean
    sqlSessionFactoryBean.setDataSource(dataSourceProxy);

    4、启动类排除

    @SpringBootApplication(exclude = {MultipartAutoConfiguration.class,DataSourceAutoConfiguration.class})

    5、file.conf 和registry.conf 与下载包里一致就可以了

    6、目前个人发现要回滚,需要加try

  • 相关阅读:
    Android Virtual Device(AVD)屏幕大小调整
    修改obj三维模型文件中坐标z为其相反数
    AE安装检测(C++)
    单件模式
    地形转立体实验截图
    保持几何特征的三维建筑物模型简化方法 毕业硕士论文
    判断多边形点串存放序列
    mathematica 查找 mathpass 注册文件位置
    在线调色板搜集
    图标资源搜集
  • 原文地址:https://www.cnblogs.com/xgyweb/p/14302314.html
Copyright © 2020-2023  润新知