zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    nginx启动,停止,重启
    获取节点与属性
    修改节点的属性 节点默认不允许修改
    删除节点与属性
    创建属性Attribute
    新增节点NewBook并增加属性Name="WPF"
    创建xml树
    HashTable Queue Stack SortedList BitArray
    ArrayList详细
    sqlserver 优化
  • 原文地址:https://www.cnblogs.com/xgyweb/p/14302314.html
Copyright © 2011-2022 走看看