spring-struts2-hibernate整合通用配置文件

本文介绍了一个使用Spring框架进行事务管理的配置示例。该配置通过声明式事务管理为数据访问层提供事务支持,并详细展示了如何设置事务传播行为以及切入点表达式。

<?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-2.0.xsd
 http://www.springframework.org/schema/aop
 http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
 http://www.springframework.org/schema/tx
 http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">

 <bean id="txManager"
  class="org.springframework.orm.hibernate3.HibernateTransactionManager">
  <property name="sessionFactory">
   <ref bean="sessionFactory" />
  </property>
 </bean>
 
 <tx:advice id="txAdvice" transaction-manager="txManager">
  <tx:attributes>
   <tx:method name="add*" propagation="REQUIRED" />
   <tx:method name="delete*" propagation="REQUIRED" />
   <tx:method name="update*" propagation="REQUIRED" />
   <tx:method name="*" propagation="SUPPORTS" />
  </tx:attributes>
 </tx:advice>
 <aop:config>
  <aop:pointcut id="txpointcut"
   expression="execution(* com.suplayer.games.dao.*.*.*(..))" />
  <aop:advisor advice-ref="txAdvice" pointcut-ref="txpointcut" />
 </aop:config>
 <bean id="datasource"
  class="org.apache.commons.dbcp.BasicDataSource">
  <property name="driverClassName"
   value="com.mysql.jdbc.Driver">
  </property>
  <property name="url"
   value="jdbc:mysql://10.30.120.13:3306/suplayer?useUnicode=true&amp;characterEncoding=utf-8&amp;zeroDateTimeBehavior=convertToNull&amp;transformedBitIsBoolean=true">

  </property>
  <property name="username" value="root"></property>
  <property name="password" value="root"></property>
 </bean>
 <bean id="sessionFactory"
  class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
  <property name="dataSource">
   <ref bean="datasource" />
  </property>

  <property name="hibernateProperties">
   <props>
    <prop key="hibernate.dialect">
     org.hibernate.dialect.MySQLDialect
    </prop>
    <prop key="hibernate.show_sql">true</prop>
   </props>
  </property>
  <property name="mappingResources">
   <list>
    <value>com/suplayer/games/entity/Active.hbm.xml</value>
    <value>
     com/suplayer/games/entity/ActiveParticipant.hbm.xml
    </value>
    <value>com/suplayer/games/entity/Album.hbm.xml</value>
    <value>com/suplayer/games/entity/Area.hbm.xml</value>
    <value>
     com/suplayer/games/entity/Association.hbm.xml
    </value>
    <value>
     com/suplayer/games/entity/AssociationMessage.hbm.xml
    </value>
    <value>
     com/suplayer/games/entity/AssociationUser.hbm.xml
    </value>
    <value>
     com/suplayer/games/entity/BasicInformation.hbm.xml
    </value>
    <value>
     com/suplayer/games/entity/Category.hbm.xml
    </value>
    <value>
     com/suplayer/games/entity/Collection.hbm.xml
    </value>
    <value>
     com/suplayer/games/entity/EnumItem.hbm.xml
    </value>
    <value>com/suplayer/games/entity/Enums.hbm.xml</value>
    <value>
     com/suplayer/games/entity/Evaluation.hbm.xml
    </value>
    <value>
     com/suplayer/games/entity/Feedback.hbm.xml
    </value>
    <value>com/suplayer/games/entity/Friend.hbm.xml</value>
    <value>com/suplayer/games/entity/Game.hbm.xml</value>
    <value>com/suplayer/games/entity/Issue.hbm.xml</value>
    <value>
     com/suplayer/games/entity/IssueAnswer.hbm.xml
    </value>
    <value>com/suplayer/games/entity/Letter.hbm.xml</value>
    <value>
     com/suplayer/games/entity/Messages.hbm.xml
    </value>
    <value>com/suplayer/games/entity/Photo.hbm.xml</value>
    <value>
     com/suplayer/games/entity/Register.hbm.xml
    </value>
    <value>com/suplayer/games/entity/Sound.hbm.xml</value>
    <value>
     com/suplayer/games/entity/Subscription.hbm.xml
    </value>
    <value>
     com/suplayer/games/entity/UserGame.hbm.xml
    </value>
    <value>
     com/suplayer/games/entity/UserHeader.hbm.xml
    </value>
    <value>
     com/suplayer/games/entity/Userinfo.hbm.xml
    </value>
    <value>
     com/suplayer/games/entity/UserMail.hbm.xml
    </value>
    <value>
     com/suplayer/games/entity/UserMakeFriendInformation.hbm.xml
    </value>
    <value>
     com/suplayer/games/entity/UserSystemInformation.hbm.xml
    </value>
    <value>com/suplayer/games/entity/Video.hbm.xml</value>
    <value>
     com/suplayer/games/entity/ViewVisitor.hbm.xml
    </value>
    <value>com/suplayer/games/entity/Visitor.hbm.xml</value>
    <value>
     com/suplayer/games/entity/UserFeedback.hbm.xml
    </value>
    <value>com/suplayer/games/entity/Patch.hbm.xml</value>
    <value>
     com/suplayer/games/entity/ActiveMessage.hbm.xml
    </value>
    <value>
     com/suplayer/games/entity/AssociationVisit.hbm.xml
    </value>
    <value>
     com/suplayer/games/entity/SystemImg.hbm.xml
    </value>
   </list>
  </property>
 </bean>
 <!-- Hibernate Template -->
 <bean id="hibernateTemplate"
  class="org.springframework.orm.hibernate3.HibernateTemplate">
  <property name="sessionFactory">
   <ref bean="sessionFactory" />
  </property>
 </bean>
 <bean id="interceptor" class="servlet.ChangeLoginInterceptor"></bean>

 

<bean id="userdao"
  class="com.suplayer.games.dao.user.impl.UserDaoImpl">
 </bean>

 

<bean id="userbiz"
  class="com.suplayer.games.biz.user.impl.UserBizImpl">
  <property name="userdao">
   <ref bean="userdao"></ref>
  </property>
 </bean>

 

<bean id="findByDate"
  class="com.suplayer.games.action.user.FindUserByDateAction"
  scope="prototype">
  <property name="userBiz" ref="userbiz"></property>
 </bean>
</beans>

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值