AOP之事务管理<aop:advisor>的两种配置方式

网友投稿 668 2022-11-20

AOP之事务管理<aop:advisor>的两种配置方式

AOP之事务管理&lt;aop:advisor&gt;的两种配置方式

目录AOP事务管理两种配置方式方式一方式二hibernate事务配置Aop aop:advisor模式

AOP事务管理两种配置方式

方式一

@transactionManagerbean.xml

xmlns:xsi="http://w3.org/2001/XMLSchema-instance"

xmlns:context="http://springframework.org/schema/context"

xmlns:aop="http://springframework.org/schema/aop" xmlns:tx="http://springframework.org/schema/tx"

xsi:schemaLocation="http://springframework.org/schema/beans http://springframework.org/schema/beans/spring-beans.xsd http://springframework.org/schema/context http://springframework.org/schema/context/spring-context.xsd http://springframework.org/schema/aop http://springframework.org/schema/aop/spring-aop.xsd http://springframework.org/schema/tx http://springframework.org/schema/tx/spring-tx.xsd">

xmlns:xsi="http://w3.org/2001/XMLSchema-instance"

xmlns:context="http://springframework.org/schema/context"

xmlns:aop="http://springframework.org/schema/aop" xmlns:tx="http://springframework.org/schema/tx"

xsi:schemaLocation="http://springframework.org/schema/beans http://springframework.org/schema/beans/spring-beans.xsd http://springframework.org/schema/context http://springframework.org/schema/context/spring-context.xsd http://springframework.org/schema/aop http://springframework.org/schema/aop/spring-aop.xsd http://springframework.org/schema/tx http://springframework.org/schema/tx/spring-tx.xsd">

ServiceImpl

在service实现类的最外层或者具体方法上添加@Transactional注解

@Service

//@Transactional

public claIsuQTsRriss CustomerServiceImpl implements CustomerService {

@Autowired

private CustomerDAO customerDAO ;

@Autowired

private LoginLogDAO loginLogDAO ;

@Transactional

@Override

public Customer login(String account, String pswd) {

return null;

}

}

方式二

bean.xml

xmlns:xsi="http://w3.org/2001/XMLSchema-instance"

xmlns:context="http://springframework.org/schema/context"

xmlns:aop="http://springframework.org/schema/aop" xmlns:tx="http://springframework.org/schema/tx"

xsi:schemaLocation="http://springframework.org/schema/beans http://springframework.org/schema/beans/spring-beans.xsd http://springframework.org/schema/context http://springframework.org/schema/context/spring-context.xsd http://springframework.org/schema/aop http://springframework.org/schema/aop/spring-aop.xsd http://springframework.org/schema/tx http://springframework.org/schema/tx/spring-tx.xsd">

http://

xmlns:xsi="http://w3.org/2001/XMLSchema-instance"

xmlns:context="http://springframework.org/schema/context"

xmlns:aop="http://springframework.org/schema/aop" xmlns:tx="http://springframework.org/schema/tx"

xsi:schemaLocation="http://springframework.org/schema/beans http://springframework.org/schema/beans/spring-beans.xsd http://springframework.org/schema/context http://springframework.org/schema/context/spring-context.xsd http://springframework.org/schema/aop http://springframework.org/schema/aop/spring-aop.xsd http://springframework.org/schema/tx http://springframework.org/schema/tx/spring-tx.xsd">

http://

hibernate事务配置Aop aop:advisor模式

class="org.springframework.orm.hibernate3.HibernateTransactionManager">

class="org.springframework.orm.hibernate3.HibernateTransactionManager">

rollback-for="Exception" />

rollback-for="Exception" />

rollback-for="Exception" />

rollback-for="Exception" />

rollback-for="Exception" />

rollback-for="Exception" />

rollback-for="Exception" />

rollback-for="Exception" />

rollback-for="Exception" />

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:查找多维数组里面的某个下标,返回新的数组
下一篇:Windows linux 下面查看端口被哪个程序占用
相关文章

 发表评论

暂时没有评论,来抢沙发吧~