zoukankan      html  css  js  c++  java
  • PlatformTransactionManager

    @Bean
    @Override
    @ConditionalOnMissingBean
    public PlatformTransactionManager annotationDrivenTransactionManager() {
    return new DataSourceTransactionManager(dataSource);
    }

    @Bean
    @ConditionalOnMissingBean
    public PlatformTransactionManager transactionManager() {
    return new DataSourceTransactionManager(dataSource);
    }

    @Bean
    public TransactionInterceptor transactionInterceptor() {
    Properties attributes = new Properties();
    attributes.setProperty("get*", "PROPAGATION_REQUIRED");
    attributes.setProperty("put*", "PROPAGATION_REQUIRED");
    attributes.setProperty("post*", "PROPAGATION_REQUIRED");
    attributes.setProperty("delete*", "PROPAGATION_REQUIRED");
    TransactionInterceptor txAdvice = new TransactionInterceptor(annotationDrivenTransactionManager(), attributes);
    return txAdvice;
    }


    @Bean
    public AspectJExpressionPointcut aspectJExpressionPointcut(){
    AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
    String transactionExecution = "execution(* " + getTransactionExecution() + "(..))";
    if(transactionExecution==null)
    transactionExecution = "execution(* com.service.impl.*.*.*(..)) || execution(* com.business.impl.*.*.*(..)) ";
    pointcut.setExpression(transactionExecution);
    return pointcut;
    }

    @Bean
    public DefaultPointcutAdvisor defaultPointcutAdvisor(){
    DefaultPointcutAdvisor advisor = new DefaultPointcutAdvisor();
    advisor.setPointcut(aspectJExpressionPointcut());
    advisor.setAdvice(transactionInterceptor());
    return advisor;
    }

  • 相关阅读:
    组件间通信
    Android抓包方法(一)之Fiddler代理
    汉字转拼音
    post请求参数问题
    post请求参数设置
    swagger
    IfcPresentationDefinitionResource(介绍定义资源)
    Java计算两个日期之间的时间差(毫秒数)
    IfcPresentationAppearanceResource(外观定义资源)
    IfcMeasureResource(度量资源)
  • 原文地址:https://www.cnblogs.com/softidea/p/5873317.html
Copyright © 2011-2022 走看看