SSH配置:spring:applicationConfig.xml

近来做了一个小项目,用到了Struts1.x,Spring 2.5和Hibernate3,其中的一些配置文件较为典型,所以拿到这里来和大家分享。
  1. <?xmlversion="1.0"encoding="UTF-8"?>
  2. <beansxmlns="http://www.springframework.org/schema/beans"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xmlns:p="http://www.springframework.org/schema/p"
  5. xmlns:aop="http://www.springframework.org/schema/aop"
  6. xmlns:tx="http://www.springframework.org/schema/tx"
  7. xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-2.5.xsd
  8. http://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop-2.5.xsd
  9. http://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
  10. <!--
  11. ======================集成Hibernate,配置SessionFactory和数据源======================
  12. -->
  13. <!--数据源由Hibernate配置-->
  14. <beanid="sessionFactory"class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
  15. <propertyname="configLocation">
  16. <value>classpath:hibernate.cfg.xml</value>
  17. </property>
  18. </bean>
  19. <!--数据源交给Spring配置
  20. <beanid="dataSource"class="org.springframework.jndi.JndiObjectFactoryBean">
  21. <propertyname="jndiName"value="jdbc/st"/>
  22. </bean>
  23. <beanid="sessionFactory"class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
  24. <propertyname="dataSource"ref="dataSource"/>
  25. <propertyname="mappingResources">
  26. <list>
  27. <value>edu/st/persistence/User.hbm.xml</value>
  28. <value>edu/st/persistence/News.hbm.xml</value>
  29. <value>edu/st/persistence/DownFile.hbm.xml</value>
  30. </list>
  31. </property>
  32. <propertyname="hibernateProperties">
  33. <props>
  34. <propkey="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
  35. <propkey="hibernate.show_sql">true</prop>
  36. <propkey="hibernate.hbm2ddl.auto">update</prop>
  37. </props>
  38. </property>
  39. </bean>
  40. -->
  41. <!--
  42. ===========================配置事务支持======================================
  43. -->
  44. <!--配置事务管理器-->
  45. <beanid="transactionManager"class="org.springframework.orm.hibernate3.HibernateTransactionManager">
  46. <propertyname="sessionFactory">
  47. <refbean="sessionFactory"/>
  48. </property>
  49. </bean>
  50. <!--配置事务的传播特性-->
  51. <tx:adviceid="txAdvice"transaction-manager="transactionManager">
  52. <tx:attributes>
  53. <tx:methodname="add"propagation="REQUIRED"/>
  54. <tx:methodname="delete"propagation="REQUIRED"/>
  55. <tx:methodname="update"propagation="REQUIRED"/>
  56. <tx:methodname="*"read-only="true"/>
  57. </tx:attributes>
  58. </tx:advice>
  59. <!--那些类的哪些方法参与事务-->
  60. <aop:config>
  61. <aop:pointcutid="allManagerMethod"expression="execution(*org.scorpio.business.*.*(..))"/>
  62. <aop:advisorpointcut-ref="allManagerMethod"advice-ref="txAdvice"/>
  63. </aop:config>
  64. <!--
  65. ===========================DAO层组件配置====================================
  66. -->
  67. <beanid="userDAO"class="org.scorpio.dao.UserDAOImpl">
  68. <propertyname="sessionFactory"ref="sessionFactory"/>
  69. </bean>
  70. <beanid="managerDAO"class="org.scorpio.dao.ManagerImpl">
  71. <propertyname="sessionFactory"ref="sessionFactory"/>
  72. </bean>
  73. <!--
  74. ==========================业务逻辑层组件配置=================================
  75. -->
  76. <beanid="userService"class="org.scorpio.business.UserServiceImpl">
  77. <propertyname="userDAO"ref="userDAO"/>
  78. </bean>
  79. <beanid="managerService"class="org.scorpio.business.ManagerServiceImpl">
  80. <propertyname="managerDAO"ref="managerDAO"/>
  81. </bean>
  82. <!--
  83. ======================集成Struts,web层的Action配置==========================
  84. -->
  85. <beanname="/userAction"class="org.scorpio.web.action.UserAction">
  86. <propertyname="userService"ref="userService"/>
  87. </bean>
  88. <beanname="/managerAction"class="org.scorpio.web.action.ManagerAction">
  89. <propertyname="managerService"ref="managerService"/>
  90. </bean>
  91. <beanname="/loginAction"class="org.scorpio.web.action.LoginAction">
  92. <propertyname="userService"ref="userService"/>
  93. <propertyname="managerService"ref="managerService"/>
  94. </bean>
  95. </beans>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值