JSP_中spring事务配置详解
来源:
中文源码网 浏览:435 次 日期:2024-05-17 12:35:11
【下载文档: JSP_中spring事务配置详解.txt 】
JSP 中spring事务配置详解
JSP 中spring事务配置详解
前几天被问到,如何防止服务器宕机,造成的数据操作的不完全。
问了一下同事,是事务。哎,恍然大悟,迷糊一时了。
声明式的事务配置,这个是最推荐的,配置到service层。
xmlns:context="http://www.springframework.org/schema/context"
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/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
expression="execution(* com.test.service.*.*(..))" />
其中,有个通配符是有点问题的。事务在于更新数据时候使用,查询不需要事务。所以直接用* ,这样太过于暴力了。
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!