SSH2项目搭建

转自:http://hefeng1987-net-163-com.iteye.com/blog/941344spring

以前说了一下我所写的这个SSH2 OA项目所用的框架与工具.今天就来总结一下从搭建SSH2开发环境的过程到即将发布的机构管理这个小模块开发的实现思路. express

我所作这个项目的目的是来巩固复习Hibernate 和Spring这两个框架(Struts2一只在用).其基本思路和架构也都想好了,也打算利用晚上下班的时间来作出来.想法赶不上计划啊!这段时间有一些其余的事情,再者感受身体不是怎么好,情绪也受到影响,可能以后就抽出空去搞了.这里就把前几天所写的来公布于众.供你们学习.因为我也是刚刚参加工做,也没什么开发经验.代码写的有不足的地方请你们提出宝贵的意见与看法. 
1.首先是搭建环境 
虽然我是的是MyEclipse来开发,但我没有借助MyEclipse来帮助我,我所有是手动的方式来构建SSH2环境的.其三个框架所依赖的jar没有一个多余的,作到jar依赖的最小化. 

整个项目架构是: 


下面是application.xml中的(applicationcontext-common.xml)关键代码: 
Java代码   收藏代码
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans"  
  3.         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  4.         xmlns:aop="http://www.springframework.org/schema/aop"  
  5.         xmlns:tx="http://www.springframework.org/schema/tx"  
  6.         xsi:schemaLocation="  
  7.             http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd  
  8.             http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd  
  9.             http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">  
  10.           
  11.     <!-- 配置sessionFactory -->  
  12.       
  13.     <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">  
  14.         <property name="configLocation">  
  15.             <value>classpath:hibernate.cfg.xml</value>  
  16.         </property>     
  17.     </bean>             
  18.       
  19.     <!-- 配置事务管理器 -->  
  20.     <!-- 配置事务管理器bean,使用HibernateTransactionManager事务管理器 -->  
  21.     <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">  
  22.         <property name="sessionFactory">  
  23.             <ref bean="sessionFactory"/>  
  24.         </property>     
  25.     </bean>  
  26.       
  27.     <!-- 配置事务的传播特性 -->  
  28.     <!-- 配置事务特性,配置add,delete,update开始的方法,事务传播特性为required -->  
  29.     <tx:advice id="txAdvice" transaction-manager="transactionManager">  
  30.         <tx:attributes>  
  31.             <tx:method name="add*" propagation="REQUIRED"/>  
  32.             <tx:method name="delete*" propagation="REQUIRED"/>  
  33.             <tx:method name="modify*" propagation="REQUIRED"/>  
  34.             <tx:method name="*" read-only="true"/>  
  35.         </tx:attributes>  
  36.     </tx:advice>  
  37.       
  38.     <!-- 那些类的哪些方法参与事务 -->  
  39.     <!--  
  40.     <aop:config>  
  41.         <aop:advisor pointcut="execution(* com.oa.manager.*.*(..))" advice-ref="txAdvice"/>  
  42.     </aop:config>   
  43.     -->   
  44.     <!-- 配置那些类的方法进行事务管理,当前com.oa.manager包中的子包, 类中全部方法须要,还须要参考tx:advice的设置 -->  
  45.     <aop:config>  
  46.         <aop:pointcut id="allManageMethod" expression="execution(* com.oa.manager.*.*(..))" />  
  47.         <aop:advisor pointcut-ref="allManageMethod" advice-ref="txAdvice"/>  
  48.     </aop:config>  
  49.       
  50.     <!-- 那些类的哪些方法参与事务 -->  
  51.     <!--  
  52.     <aop:config>  
  53.         <aop:advisor pointcut="execution(* com.oa.manager.*.*(..))" advice-ref="txAdvice"/>  
  54.     </aop:config>   
  55.     -->  
  56.     </beans>  

2.机构管理的功能实现: 


代码我打包上传了,效果实现过程能够看我所写的代码.(不知道怎么搞的,它不让我上传了!!!) 
相关文章
相关标签/搜索