日期:2014-05-17  浏览次数:20748 次

application.xml文件中的一个问题
<bean id="Ilogon" class="com.fenghui.system.business.Logon">
  <property name="sessionFactory">
  <ref local="sessionFactory"/>
  </property>
  </bean>
  <bean id="logonBOProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
  <property name="transactionManager">
  <ref bean="transactionManager" />
  </property>
  <property name="target">
  <ref local="Ilogon" />
  </property>
  <property name="transactionAttributes">
  <props>
  <prop key="insert*">PROPAGATION_REQUIRED</prop>
  <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
  </props>
  </property>
  </bean>
  <bean name="/logonAction" class="com.fenghui.system.action.LogonAction" scope="prototype">
  <property name="logon">
  <ref bean="logonBOProxy" />
  </property>
  </bean>

这个是application.xml文件中的代码,第一个<bean>是将SessionFactory注入到dao中,第三个<bean>是dao注入到action中,但是第二个<bean>的功能是什么,各位大虾能不能具体的说一说,谢谢!

------解决方案--------------------
第二个Bean logonBOProxy 是对第一个bean Ilogon的代理类, Spring AOP会为这个代理类增加事务管理,事务管理是由transactionManager管理的,当你调用这个代理类的insert*,get*方法,会产生事务
------解决方案--------------------
<property name="target">
<ref local="Ilogon" />
</property> 
配置你要增强的原始的对象,target=Ilogon;

<property name="transactionAttributes"> 配置事务匹配
------解决方案--------------------
LS 正解,简单地了讲就是为insert*,get*方法绑定事务。
------解决方案--------------------
org.springframework.transaction.interceptor.TransactionProxyFactoryBean

配置 事物保护的