spring配置的一些问题

feiling111222 2009-04-28 04:09:58
由于初学SPRING,对配置不太深入,所以想请教各位
(1):我用了<tx:annotation-driven transaction-manager="txManager"/>

(2)<!-- 那些类使用事务 -->
<aop:config>
<aop:pointcut id="point-cut" expression="execution(* com.wlh.spring.manager.*.*(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="point-cut"/>
</aop:config>
(1)和(2)有什么区别呢?
(1)我试过了好象也可以在任何地方用的,那么既然有了(1)了为什么还要有(2)呢,这两者到底有什么不同呢?哪个更强大呢,有了(2)还要不要(1)呢


<!-- 配置事务传播特性 -->
<tx:advice id="txAdvice" transaction-manager="transactionMgr">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED"/>
<tx:method name="del*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="*" read-only="true"/>
</tx:attributes>
</tx:advice> 这个又是指什么意思呢?难道前面的事务配置还不包括这些add,insert,del等语句吗?蒙!!蒙啊!谁来救我啊!!!
...全文
87 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
michaelpeng7799 2009-05-22
  • 打赏
  • 举报
回复
(1)是在需要事务的方法上用 @Transactional标识,然后在XML中用(1)中那样声明就行了,意思是告诉程序用使用 @Transactional标识的方法是需要事务的。
(2)是另一种配置方法,纯XML配置,以那几个add,del,update开头的方法,AOP会被拦截从而对方法加入事务管里你,可以看看有关Spring AOP的知识就容易明白了。

其实效果一样,实现手法不同:)
feiling111222 2009-04-29
  • 打赏
  • 举报
回复
晕,你们说的我都知道啊。可是你们看看我问的是什么呢?有没有真正了解的高手来回答下~
谢谢了!!
feiling111222 2009-04-29
  • 打赏
  • 举报
回复
还有谁了解的更详细的吗
还没说 <tx:annotation-driven transaction-manager="txManager"/>

<aop:config>
<aop:pointcut id="point-cut" expression="execution(* com.wlh.spring.manager.*.*(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="point-cut"/>
</aop:config>
有什么区别呢?
哪位高手来解答下啊。。。
jumpheightway 2009-04-29
  • 打赏
  • 举报
回复
<tx:advice id="txAdvice" transaction-manager="transactionMgr">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED"/>
<tx:method name="del*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="*" read-only="true"/>
</tx:attributes>
</tx:advice>
这个表示运行规则是先运行还是后运行
GeekZFZ 2009-04-28
  • 打赏
  • 举报
回复
学习
gHost241 2009-04-28
  • 打赏
  • 举报
回复
(2) <!-- 那些类使用事务 -->
<aop:config>
<aop:pointcut id="point-cut" expression="execution(* com.wlh.spring.manager.*.*(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="point-cut"/>
</aop:config>
____________________________________________________________________
这些事spring对AOP(面向切面编程)的一些配置.
________________________________________________
<!-- 配置事务传播特性 -->
<tx:advice id="txAdvice" transaction-manager="transactionMgr">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED"/>
<tx:method name="del*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="*" read-only="true"/>
</tx:attributes>
</tx:advice>
____________________________________________________
这个是spring对事务控制的配置信息,也就是说,在spring中,对增删改做一个事务的处理.
nick207 2009-04-28
  • 打赏
  • 举报
回复
add del update 指的是你上面配置文件中 com.wlh.spring.manager类中的方法中 以add del update命名开头的方法用到了 事物
Defonds 2009-04-28
  • 打赏
  • 举报
回复
我的资源里有本spring参考手册,介绍的不错。有需要的朋友可以去看看

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧