SpringBoot 注解事务声明式事务

python特征选择pso_【来点干货】机器学习中常用的特征选择方法及非常详细的Python实例... 花费了很长时间整理编辑,转载请联系作者授权,违者必究。特征选择(Feature selection)是在构建预测模型的过程中减少输入变量的一个过程。它是机器学习中非常重要的一步并在很大程度上可以提高模型预测精度。这里我总结了一些机器学习中常见的比较有用的特征选择方法并附上相关python实现code。希望可以给大家一些启发。首先,我们为什么要进行特征选择呢?它有以下几个优点:减少过拟合:冗余数据常... 阅读详情

 springboot 对新人来说可能上手比springmvc要快,但是对于各位从springmvc转战到springboot的话,有些地方还需要适应下,尤其是xml配置。我个人是比较喜欢注解➕xml是因为看着方便,查找方便,清晰明了。但是xml完全可以使用注解代替,今天就扒一扒springboot中事务使用注解的玩法。

  springboot的事务也主要分为两大类,一是xml声明式事务,二是注解事务,注解事务也可以实现类似声明式事务的方法,关于注解声明式事务,目前网上搜索不到合适的资料,所以在这里,我将自己查找和总结的几个方法写到这里,大家共同探讨

    文章来源: http://www.cnblogs.com/guozp/articles/7446477.html 

  • springboot 之 xml事务

      可以使用 @ImportResource("classpath:transaction.xml") 引入该xml的配置,xml的配置如下

  

复制代码
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/tx
        http://www.springframework.org/schema/tx/spring-tx.xsd
        http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop.xsd">
        
    <bean id="txManager"
        class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource" ></property>
    </bean>
    <tx:advice id="cftxAdvice" transaction-manager="txManager">
        <tx:attributes>
            <tx:method name="query*" propagation="SUPPORTS" read-only="true" ></tx:method>
            <tx:method name="get*" propagation="SUPPORTS" read-only="true" ></tx:method>
            <tx:method name="select*" propagation="SUPPORTS" read-only="true" ></tx:method>
            <tx:method name="*" propagation="REQUIRED" rollback-for="Exception" ></tx:method>
        </tx:attributes>
    </tx:advice>
     <aop:config>
        <aop:pointcut id="allManagerMethod" expression="execution (* com.exmaple.fm..service.*.*(..))" />
        <aop:advisor advice-ref="txAdvice" pointcut-ref="allManagerMethod" order="0" />
    </aop:config>

</beans>
复制代码

springboot 启动类如下:

  

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
package  com.example.fm;
 
import  org.springframework.boot.SpringApplication;
import  org.springframework.boot.autoconfigure.SpringBootApplication;
import  org.springframework.context.annotation.ImportResource;
 
@ImportResource ( "classpath:transaction.xml" )
@SpringBootApplication
public  class  Application {
 
     public  static  void  main(String[] args) {
         SpringApplication.run(Application. class , args);
     }
 
}

  启动后即可开启事务,不过项目里导入了xml配置,如果不想导入xml配置,可以使用注解的方式。

  • springboot 之 注解事务

   注解事务讲解之前,需要先了解下spring创建代理的几个类,在spring内部,是通过BeanPostProcessor来完成自动创建代理工作的。BeanPostProcessor接口的实现只是在ApplicationContext初始化的时候才会自动加载,而普通的BeanFactory只能通过编程的方式调用之。根据  匹配规则的不同大致分为三种类别:

    a、匹配Bean的名称自动创建匹配到的Bean的代理,实现类BeanNameAutoProxyCreator

    

复制代码
<bean id="testInterceptor" class="com.example.service.config.testInerceptor”></bean>

<bean id="profileAutoProxyCreator" class="org.springframework.aop.framework.
autoproxy.BeanNameAutoProxyProxyCreator">
<bean>
<property name="beanNames">
<list>
<value>*Service</value>
</list>
</property>
<property name="interceptorNames">
<value> testInterceptor </value>
</property>
</bean>
复制代码

 

    b、根据Bean中的AspectJ注解自动创建代理,实现类AnnotationAwareAspectJAutoProxyCreator

复制代码
<aop:aspectj-autoproxy proxy-target-class="true"/>

<bean id="annotationAwareAspectJAutoProxyCreatorTest" class="com.example.service.AnnotationAwareAspectJAutoProxyCreatorTest"/>
<aop:config>
    <aop:aspect ref="annotationAwareAspectJAutoProxyCreatorTest">
        <aop:around method="process" pointcut="execution (* com.example.service.fm..*.*(..))"/>
    </aop:aspect>
</aop:config>
复制代码

 

    c、根据Advisor的匹配机制自动创建代理,会对容器中所有的Advisor进行扫描,自动将这些切面应用到匹配的Bean中,实现类DefaultAdvisorAutoProxyCreator

  

  接下来开讲注解开启事务的方法:

       1、Transactional注解事务

   需要在进行事物管理的方法上添加注解@Transactional,或者偷懒的话直接在类上面添加该注解,使得所有的方法都进行事物的管理,但是依然需要在需要事务管理的类上都添加,工作量比较大,这里只是简单说下,具体的可以google或者bing

       2、注解声明式事务

  Component或Configuration中bean的区别,有时间我会专门写一篇来讲解下

  a.方式1,这里使用Component或Configuration事务都可以生效

   

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package  com.exmple.service.fm9.config;
 
import  java.util.Collections;
import  java.util.HashMap;
import  java.util.Map;
 
import  org.aspectj.lang.annotation.Aspect;
import  org.springframework.aop.Advisor;
import  org.springframework.aop.aspectj.AspectJExpressionPointcut;
import  org.springframework.aop.support.DefaultPointcutAdvisor;
import  org.springframework.beans.factory.annotation.Autowired;
import  org.springframework.context.annotation.Bean;
import  org.springframework.context.annotation.Configuration;
import  org.springframework.stereotype.Component;
import  org.springframework.transaction.PlatformTransactionManager;
import  org.springframework.transaction.TransactionDefinition;
import  org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource;
import  org.springframework.transaction.interceptor.RollbackRuleAttribute;
import  org.springframework.transaction.interceptor.RuleBasedTransactionAttribute;
import  org.springframework.transaction.interceptor.TransactionAttribute;
import  org.springframework.transaction.interceptor.TransactionInterceptor;
 
/**
  * Created by guozp on 2017/8/28.
  */
@Aspect
//@Component 事务依然生效
@Configuration
public  class  TxAdviceInterceptor {
 
     private  static  final  int  TX_METHOD_TIMEOUT =  5 ;
     private  static  final  String AOP_POINTCUT_EXPRESSION =  "execution (* com.alibaba.fm9..service.*.*(..))" ;
 
     @Autowired
     private  PlatformTransactionManager transactionManager;
 
     @Bean
     public  TransactionInterceptor txAdvice() {
         NameMatchTransactionAttributeSource source =  new  NameMatchTransactionAttributeSource();
          /*只读事务,不做更新操作*/
         RuleBasedTransactionAttribute readOnlyTx =  new  RuleBasedTransactionAttribute();
         readOnlyTx.setReadOnly( true );
         readOnlyTx.setPropagationBehavior(TransactionDefinition.PROPAGATION_NOT_SUPPORTED );
         /*当前存在事务就使用当前事务,当前不存在事务就创建一个新的事务*/
         RuleBasedTransactionAttribute requiredTx =  new  RuleBasedTransactionAttribute();
         requiredTx.setRollbackRules(
             Collections.singletonList( new  RollbackRuleAttribute(Exception. class )));
         requiredTx.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
         requiredTx.setTimeout(TX_METHOD_TIMEOUT);
         Map<String, TransactionAttribute> txMap =  new  HashMap<>();
         txMap.put( "add*" , requiredTx);
         txMap.put( "save*" , requiredTx);
         txMap.put( "insert*" , requiredTx);
         txMap.put( "update*" , requiredTx);
         txMap.put( "delete*" , requiredTx);
         txMap.put( "get*" , readOnlyTx);
         txMap.put( "query*" , readOnlyTx);
         source.setNameMap( txMap );
         TransactionInterceptor txAdvice =  new  TransactionInterceptor(transactionManager, source);
         return  txAdvice;
     }
 
     @Bean
     public  Advisor txAdviceAdvisor() {
         AspectJExpressionPointcut pointcut =  new  AspectJExpressionPointcut();
         pointcut.setExpression(AOP_POINTCUT_EXPRESSION);
         return  new  DefaultPointcutAdvisor(pointcut, txAdvice());
         //return new DefaultPointcutAdvisor(pointcut, txAdvice);
     }
}

  

 b.方式1,这里使用Component或Configuration事务都可以生效

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package  com.exmple.service.fm9.config;
 
import  java.util.Collections;
import  java.util.HashMap;
import  java.util.Map;
 
import  org.springframework.aop.aspectj.AspectJExpressionPointcutAdvisor;
import  org.springframework.beans.factory.annotation.Autowired;
import  org.springframework.context.annotation.Bean;
import  org.springframework.context.annotation.Configuration;
import  org.springframework.stereotype.Component;
import  org.springframework.transaction.PlatformTransactionManager;
import  org.springframework.transaction.TransactionDefinition;
import  org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource;
import  org.springframework.transaction.interceptor.RollbackRuleAttribute;
import  org.springframework.transaction.interceptor.RuleBasedTransactionAttribute;
import  org.springframework.transaction.interceptor.TransactionAttribute;
import  org.springframework.transaction.interceptor.TransactionAttributeSource;
import  org.springframework.transaction.interceptor.TransactionInterceptor;
 
/**
  * Created by guozp on 2017/8/29.
  */
//@Component 事务依然生效
@Configuration
public  class  TxAnoConfig {
     /*事务拦截类型*/
     @Bean ( "txSource" )
     public  TransactionAttributeSource transactionAttributeSource(){
         NameMatchTransactionAttributeSource source =  new  NameMatchTransactionAttributeSource();
          /*只读事务,不做更新操作*/
         RuleBasedTransactionAttribute readOnlyTx =  new  RuleBasedTransactionAttribute();
         readOnlyTx.setReadOnly( true );
         readOnlyTx.setPropagationBehavior(TransactionDefinition.PROPAGATION_NOT_SUPPORTED );
         /*当前存在事务就使用当前事务,当前不存在事务就创建一个新的事务*/
         //RuleBasedTransactionAttribute requiredTx = new RuleBasedTransactionAttribute();
         //requiredTx.setRollbackRules(
         //    Collections.singletonList(new RollbackRuleAttribute(Exception.class)));
         //requiredTx.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
         RuleBasedTransactionAttribute requiredTx =  new  RuleBasedTransactionAttribute(TransactionDefinition.PROPAGATION_REQUIRED,
             Collections.singletonList( new  RollbackRuleAttribute(Exception. class )));
         requiredTx.setTimeout( 5 );
         Map<String, TransactionAttribute> txMap =  new  HashMap<>();
         txMap.put( "add*" , requiredTx);
         txMap.put( "save*" , requiredTx);
         txMap.put( "insert*" , requiredTx);
         txMap.put( "update*" , requiredTx);
         txMap.put( "delete*" , requiredTx);
         txMap.put( "get*" , readOnlyTx);
         txMap.put( "query*" , readOnlyTx);
         source.setNameMap( txMap );
 
         return  source;
     }
 
     /**切面拦截规则 参数会自动从容器中注入*/
     @Bean
     public  AspectJExpressionPointcutAdvisor pointcutAdvisor(TransactionInterceptor txInterceptor){
         AspectJExpressionPointcutAdvisor pointcutAdvisor =  new  AspectJExpressionPointcutAdvisor();
         pointcutAdvisor.setAdvice(txInterceptor);
         pointcutAdvisor.setExpression( "execution (* com.alibaba.fm9..service.*.*(..))" );
         return  pointcutAdvisor;
     }
 
     /*事务拦截器*/
     @Bean ( "txInterceptor" )
     TransactionInterceptor getTransactionInterceptor(PlatformTransactionManager tx){
         return  new  TransactionInterceptor(tx , transactionAttributeSource()) ;
     }
}

  

 c.方式1,这里使用Component或Configuration事务都可以生效

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package  com.exmple.service.fm9.config;
 
import  java.util.Properties;
 
 
import  org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator;
import  org.springframework.beans.factory.annotation.Autowired;
import  org.springframework.context.annotation.Bean;
import  org.springframework.context.annotation.Configuration;
import  org.springframework.jdbc.datasource.DataSourceTransactionManager;
import  org.springframework.stereotype.Component;
import  org.springframework.transaction.interceptor.TransactionInterceptor;
 
/**
  * Created by guozp on 2017/8/28.
  *
  */
//@Component
@Configuration
public  class  TxConfigBeanName {
 
     @Autowired
     private  DataSourceTransactionManager transactionManager;
 
     // 创建事务通知
 
     @Bean (name =  "txAdvice" )
     public  TransactionInterceptor getAdvisor()  throws  Exception {
 
         Properties properties =  new  Properties();
         properties.setProperty( "get*" ,  "PROPAGATION_REQUIRED,-Exception,readOnly" );
         properties.setProperty( "add*" ,  "PROPAGATION_REQUIRED,-Exception,readOnly" );
         properties.setProperty( "save*" ,  "PROPAGATION_REQUIRED,-Exception,readOnly" );
         properties.setProperty( "update*" ,  "PROPAGATION_REQUIRED,-Exception,readOnly" );
         properties.setProperty( "delete*" ,  "PROPAGATION_REQUIRED,-Exception,readOnly" );
 
         TransactionInterceptor tsi =  new  TransactionInterceptor(transactionManager,properties);
         return  tsi;
 
     }
 
     @Bean
     public  BeanNameAutoProxyCreator txProxy() {
         BeanNameAutoProxyCreator creator =  new  BeanNameAutoProxyCreator();
         creator.setInterceptorNames( "txAdvice" );
         creator.setBeanNames( "*Service" ,  "*ServiceImpl" );
         creator.setProxyTargetClass( true );
         return  creator;
     }
}

  

 

 d.方式1,这里使用Component或Configuration并不是所有事务都可以生效,例如Configuration的时候如果打开注释部分的而且不把代码都移动到 defaultPointcutAdvisor(),事物会失效,具体原因暂时不明,如果各位有明白的,可以指点我下。

初始使用:

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package  com.alibaba.fm9.config;
 
import  java.util.Properties;
 
import  javax.sql.DataSource;
 
import  org.springframework.aop.aspectj.AspectJExpressionPointcut;
import  org.springframework.aop.support.DefaultPointcutAdvisor;
import  org.springframework.beans.factory.annotation.Autowired;
import  org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import  org.springframework.context.annotation.Bean;
import  org.springframework.context.annotation.Configuration;
import  org.springframework.jdbc.datasource.DataSourceTransactionManager;
import  org.springframework.stereotype.Component;
import  org.springframework.transaction.interceptor.TransactionInterceptor;
 
/**
  * Created by guozp on 2017/8/28.  ??
  */
@Component
//@Configuration  事务失败
public  class  TxOtherConfigDefault {
 
    @Autowired
     private  DataSource dataSource;
 
     //@Bean
     //@ConditionalOnMissingBean
     public  PlatformTransactionManager annotationDrivenTransactionManager() {
         return  new  DataSourceTransactionManager(dataSource);
     }*/
 
    @Autowired
    private  DataSourceTransactionManager transactionManager;
 
 
     @Bean
     public  TransactionInterceptor transactionInterceptor() {
         Properties attributes =  new  Properties();
         attributes.setProperty( "get*" ,  "PROPAGATION_REQUIRED" );
         attributes.setProperty( "add*" ,  "PROPAGATION_REQUIRED" );
         attributes.setProperty( "update*" ,  "PROPAGATION_REQUIRED" );
         attributes.setProperty( "delete*" ,  "PROPAGATION_REQUIRED" );
         TransactionInterceptor txAdvice =  new  TransactionInterceptor(transactionManager, attributes);
         return  txAdvice;
     }
 
 
     @Bean
     public  AspectJExpressionPointcut aspectJExpressionPointcut(){
         AspectJExpressionPointcut pointcut =  new  AspectJExpressionPointcut();
         String transactionExecution =  "execution (* com.alibaba.fm9..service.*.*(..))" ;
         pointcut.setExpression(transactionExecution);
         return  pointcut;
     }
 
     @Bean
     public  DefaultPointcutAdvisor defaultPointcutAdvisor(){
         DefaultPointcutAdvisor advisor =  new  DefaultPointcutAdvisor();
         advisor.setPointcut(aspectJExpressionPointcut());
         advisor.setAdvice(transactionInterceptor());
         return  advisor;
     }
}

  

 

后修改如下:

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
ackage com.alibaba.fm9.config;
 
import  java.util.Properties;
 
import  javax.sql.DataSource;
 
import  org.springframework.aop.aspectj.AspectJExpressionPointcut;
import  org.springframework.aop.support.DefaultPointcutAdvisor;
import  org.springframework.beans.factory.annotation.Autowired;
import  org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import  org.springframework.context.annotation.Bean;
import  org.springframework.context.annotation.Configuration;
import  org.springframework.jdbc.datasource.DataSourceTransactionManager;
import  org.springframework.stereotype.Component;
import  org.springframework.transaction.PlatformTransactionManager;
import  org.springframework.transaction.interceptor.TransactionInterceptor;
 
/**
  * Created by guozp on 2017/8/28.
  *                       ???????
  */
@Configuration  //事务失效,都移动到一个方法不失效
//@Component // 事务可行,不用都移动到一个方法
public  class  TxOtherConfigDefaultBean {
 
     public  static  final  String transactionExecution =  "execution (* com.alibaba.fm9..service.*.*(..))" ;
 
     @Autowired
     private  PlatformTransactionManager transactionManager;
 
     //@Bean
     //@ConditionalOnMissingBean
     //public PlatformTransactionManager transactionManager() {
     //    return new DataSourceTransactionManager(dataSource);
     //}
 
 
     @Bean
     public  TransactionInterceptor transactionInterceptor() {
         Properties attributes =  new  Properties();
         attributes.setProperty( "get*" ,  "PROPAGATION_REQUIRED,-Exception" );
         attributes.setProperty( "add*" ,  "PROPAGATION_REQUIRED,-Exception" );
         attributes.setProperty( "update*" ,  "PROPAGATION_REQUIRED,-Exception" );
         attributes.setProperty( "delete*" ,  "PROPAGATION_REQUIRED,-Exception" );
         //TransactionInterceptor txAdvice = new TransactionInterceptor(transactionManager(), attributes);
         TransactionInterceptor txAdvice =  new  TransactionInterceptor(transactionManager, attributes);
         return  txAdvice;
     }
 
 
     //@Bean
     //public AspectJExpressionPointcut aspectJExpressionPointcut(){
     //    AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
     //    pointcut.setExpression(transactionExecution);
     //    return pointcut;
     //}
 
     @Bean
     public  DefaultPointcutAdvisor defaultPointcutAdvisor(){
         //AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
         //pointcut.setExpression(transactionExecution);
         //DefaultPointcutAdvisor advisor = new DefaultPointcutAdvisor();
         //advisor.setPointcut(pointcut);
         //advisor.setAdvice(transactionInterceptor());
         AspectJExpressionPointcut pointcut =  new  AspectJExpressionPointcut();
         pointcut.setExpression(transactionExecution);
         DefaultPointcutAdvisor advisor =  new  DefaultPointcutAdvisor();
         advisor.setPointcut(pointcut);
         Properties attributes =  new  Properties();
         attributes.setProperty( "get*" ,  "PROPAGATION_REQUIRED,-Exception" );
         attributes.setProperty( "add*" ,  "PROPAGATION_REQUIRED,-Exception" );
         attributes.setProperty( "update*" ,  "PROPAGATION_REQUIRED,-Exception" );
         attributes.setProperty( "delete*" ,  "PROPAGATION_REQUIRED,-Exception" );
         TransactionInterceptor txAdvice =  new  TransactionInterceptor(transactionManager, attributes);
         advisor.setAdvice(txAdvice);
         return  advisor;
     }
}

    

  简单来说,springboot使用上述注解的几种方式开启事物,可以达到和xml中声明的同样效果,但是却告别了xml,使你的代码远离配置文件。

    如果有错误的地方,望各位指正。如有其它问题,可以联系

   文章来源: http://www.cnblogs.com/guozp/articles/7446477.html 

把对讲门铃(控制底楼铁门)接入米家服务器 今天讲个跟SDR或者无人机无关的东西,技术含量不高,但是方便了我的生活。 现在家门有智能锁,汽车也可以远程解锁发动,NFC门禁也可以用某些手机复制,唯独楼下的铁门,必须用老式对讲门铃控制。 也就是说其它钥匙都可以不带,就剩这个钥匙还必须随身携带。 另外有时候人不在家,不能开楼下铁门,快递员也没法把东西送上楼。 ...... 阅读详情

相关推荐

【嵌入式底层知识修炼】按键和LED共用IO口的分时复用扫描方法

文章目录01 - PCB原理图例程02 - 分时复用的注意项和设计2.1 - 注意项2.2 - 设计03 - 代码实现 只要我跑的速度够快,寂寞就追不上我 只要Key和Led切换速度够快,人眼就看不出来 ————小白   如果你存在按键Key和显示Led共用同一个IO时,需要分时复用的需求,则可以移植代码进行使用: 代码所占code少于0.5K 线程安全,中断安全 可移植性高,配置容易 注意:系统需要存在一个至少为1ms的时钟中断 01 - PCB原理图例程   举2个Key和Led共用IO口的

单眼皮根号三的博客 1万+

[微服务感悟] 很好理解的分布式事务

分布式事务跨服务的事务的处理。对于分布式事务,处理起来都比较麻烦,首先应该考虑是否可以避开分布式事务,如因为服务拆分过细而出现分布式事务,就应该把微服务合并成一个,并处理本地事务。 tcc和事务管理器是两种十分常见的分布式事务模式,前者更适用于分布式的场景,后者无实现成功,框架可以傻瓜的解决一切。 tcc分布式事务 tcc是Try - Confirm - Cancel的简写,使用这种分布式事务,需...

咸鱼老罗的博客 838

Geant4学习一:写一个简单程序

1、 基本介绍

ccwwNUAA的博客 7706

Spring的 事务传播行为类型

先看下Spring的 事务传播行为类型事务传播行为类型说明PROPAGATION_REQUIRED如果当前没有事务,就新建一个事务,如果已经存在一个事务中,加入到这个事务中。这是 最常见的选择。PROPAGATION_SUPPORTS支持当前事务,如果当前没有事务,就以非事务方式执行。PROPAGATION_MANDATORY使用当前的事务,如果当前没有事务,就抛出异常。PROPAGATION_R...

gaoyong_stone的博客 414

《Python星球日记》 第73天:情感分析与主题建模

《Python星球日记》 第73天:情感分析与主题建模,今天我们将探索两个自然语言处理领域的重要技术:情感分析和主题建模。这两项技术在社交媒体分析、用户反馈处理、市场研究等多个领域有着广泛应用。

Code_流苏:在代码中寻诗意,在实践中觅真知 924

Android 12.0 framework系统修改安兔兔等显示的屏幕尺寸大小功能实现

在12.0的系统rom定制化开发中,在使用第三方app检测系统的一些信息中,比如安兔兔 设备信息等检测app中,有时候显示的屏幕尺寸大小和 产品规格书等信息不同,稍微有些差异,所以就需要看下系统framework层中,相关的设备信息是怎么读出来的,然后做些调整 接下来就来分析相关功能

安卓兼职framework和app工程师的博客 482

【老王读Spring Transaction-3】TransactionDefinition原理和源码解析

前文在分析@Transactional是如何被解析的时候讲到,@Transactional 配置的事务属性被解析出来之后,被放在了当中。是 Spring 中用来定义事务属性的接口,它继承自。下面就来详细分析一下的作用。

老王的专栏 1086

IMX335摄像头原理图设计,已量产

从工程组织上看,IMX335 模组和 IMX415 模组属于同一类产品:核心矛盾不是外设多,而是高速图像链路、电源域和调试接口要同时兼顾。ATK-MCIMX335 这张图的结构也很直接,三路 LDO、本地 24MHz 可选时钟、4-lane MIPI 数据对和一组主板侧标准接口,构成了一张非常典型的量产摄像头子板。

不脱发的程序猿 471

Spring Boot 全局事务配置

什么是全局事务Spring Boot(Spring)事务是通过aop(aop相关术语:通知(Advice)、连接点(Joinpoint)、切入点(Pointcut)、切面(Aspect)、目标(Target)、代理(Proxy)、织入(Weaving))切面编程来实现的,此时我们就可以对指定的包的service的方法进行事务控制. 为什么要使用全局事务在实际开发中,有些同学命名方法时不规范,多个成员开发时,会造成混乱,维护成本特别高,代码可读性不高. 怎么配置Spring Boot全局事务Spri...

weixin_38982591的博客 903

YOLOv13改进策略【多YAML融合】| HWD + DSC3k2_PConv + Detect_MBConv

本文记录的是利用HWD + DSC3k2_PConv + Detect_MBConv改进YOLOv13,分别涉及骨干、颈部和检测头部分的改进。一方面按照此配置,其工作量及创新程度能够满足论文发表的需求,另一方面是一些难以融合多个YAML的举例,以帮助大家理解如何将多个YAML整合到一个YAML中。小波下采样:一个简单但有效的语义分割下采样模块。块由两个主要块组成:无损特征编码块和特征表示学习块。HWD模块与其他下采样模块对比:保留信息能力:传统的下采样方法(如最大池化、平均池化和步幅卷积等)会导致信息丢失,

Limiiiing的博客 507

半导体晶圆调平系统:基于最小二乘法的实现方案

基于最小二乘法的晶圆调平技术通过数学建模与工程实现的结合,解决了半导体量测中高精度平面对准的核心问题。实际应用中,需根据设备特性优化采样策略、校准传感器误差,并通过实时性优化满足高产能场景需求。该方案的模块化设计(如分离数据采集、拟合计算、补偿输出)也为后续功能扩展(如引入机器学习优化拟合模型)提供了灵活性。

品质生活,极致编程。 1192

Springboot2(47)注解事务声明式事务

源码地址 springboot2教程系列 springboot的事务也主要分为两大类,一是xml声明式事务,二是注解事务,注解事务也可以实现类似声明式事务的方法,关于注解声明式事务,目前网上搜索不到合适的资料,所以在这里,我将自己查找和总结的几个方法写到这里,大家共同探讨 引入依赖 <dependency> <groupId>org.springframewor...

cowbin2012的专栏 2万+

别再写XPath改DOM了!用OpenClaw零代码搞定爬虫全流程(抓取+清洗+存储)

免费版的大模型调用次数有限制(每天100次),但企业版是无限的,还能私有化部署;大模型分析DOM结构有时候会慢1-2秒,但比起节省的时间,完全可以接受;自定义Skill的文档还不够完善,但社区很活跃,有问题在Discord里问,很快就能得到回复。但总的来说,OpenClaw真的改变了我写爬虫的方式——以前我是“代码的奴隶”,现在我是“需求的提出者”,把时间花在更有价值的业务逻辑上,而不是重复繁琐的DOM调试上。如果你也在被传统爬虫折磨,强烈建议你试试OpenClaw,相信我,用了就回不去了。

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 1320

Springboot2注解事务声明式事务

源码地址 springboot2教程系列 springboot的事务也主要分为两大类,一是xml声明式事务,二是注解事务,注解事务也可以实现类似声明式事务的方法,关于注解声明式事务,目前网上搜索不到合适的资料,所以在这里,我将自己查找和总结的几个方法写到这里,大家共同探讨。 引入依赖 <dependency> <groupId>org.springfram...

我爱编程持之以恒 928

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

SpringBoot 注解事务声明式事务的方式

SpringBoot 注解事务声明式事务的方式更多干货分布式实战(干货)spring cloud 实战(干货)mybatis 实战(干货)spring boot 实战(干货)React 入门实战(干货)构建中小型互联网企业架构(干货)python 学习持续更新ElasticSearch 笔记springboot使用上述注解的几种方式开启事物,可以达到和xml中声明的同样效果,但是却告别了xml,使...

架构师的成长之路的博客 8647

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

spring boot基于注解的声明式事务配置

spring boot基于注解的声明式事务配置 事务配置 1、配置方式一 1)开启spring事务管理,在spring boot启动类添加注解@EnableTransactionManagement(proxyTargetClass = true);等同于xml配置方式的 (注意:1项目中只需配置一次,2需要配置proxyTargetClass = true) 2)在项目中需要添加事务的类

Kai辉的专栏 2591

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

SpringBoot XML、注解事务声明式事务

springboot 对新人来说可能上手比springmvc要快,但是对于各位从springmvc转战到springboot的话,有些地方还需要适应下,尤其是xml配置。我个人是比较喜欢注解➕xml是因为看着方便,查找方便,清晰明了。但是xml完全可以使用注解代替,今天就扒一扒springboot中事务使用注解的玩法。   springboot的事务也主要分为两大类,一是xml声明式事务,二

很多时候犯错都是在不知情的情况下发生的 2140

Springboot声明式(@Transactional注解)事务失效场景

②:如果同类中A方法调用B方法,被调用方法B使用@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)注解修饰,REQUIRES_NEW表示新开一个事务,那么事务也不会生效。因为@Transaction要生效,需要经过Spring的代理类,所以只有来自外部方法调用被AOP代理成功捕获,也就是类内部方法调用本类中其他方法不会引起事务行为。解决方法:方法A和方法B都支持事务。

qq_41759440的博客 780

@transactional注解_SpringBoot 系列教程之声明式事务 Transactional

200119-SpringBoot 系列教程之声明式事务 Transactional当我们希望一组操作,要么都成功,要么都失败时,往往会考虑利用事务来实现这一点;之前介绍的 db 操作,主要在于单表的 CURD,本文将主要介绍声明式事务@Transactional的使用姿势I. 配置本篇主要介绍的是jdbcTemplate配合事务注解@Transactional的使用姿势,至于 JPA,mybat...

weixin_39891317的博客 169

Springboot种声明式事务(@Transactional注解)不生效的场景

Springboot种声明式事务(@Transactional注解)常见的不生效场景

weixin_45502734的博客 1793
上一篇: SpringBoot之集成Spring AOP
下一篇: MyBatis的flushCache和useCache的使用
hxpjava1
博客等级 码龄19年 1365粉丝 511原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址