转自:
之前说了一下我所写的这个SSH2 OA项目所用的框架与工具.今天就来总结一下从搭建SSH2开发环境的过程到即将发布的机构管理这个小模块开发的实现思路.
我所做这个项目的目的是来巩固复习Hibernate 和Spring这两个框架(Struts2一只在用).其基本思路和架构也都想好了,也打算利用晚上下班的时间来做出来.想法赶不上计划啊!这段时间有一些其他的事情,再者感觉身体不是怎么好,情绪也受到影响,可能之后就抽出空去搞了.这里就把前几天所写的来公布于众.供大家学习.由于我也是刚刚参加工作,也没什么开发经验.代码写的有不足的地方请大家提出宝贵的意见与见解. 1.首先是搭建环境 虽然我是的是MyEclipse来开发,但我没有借助MyEclipse来帮助我,我全部是手动的方式来构建SSH2环境的.其三个框架所依赖的jar没有一个多余的,做到jar依赖的最小化.![点击查看原始大小图片](https://static.oschina.net/uploads/img/201710/18111026_VqO5.png)
![点击查看原始大小图片](https://static.oschina.net/uploads/img/201710/18111026_PvOv.png)
- <?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.5.xsd
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
- http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
- <!-- 配置sessionFactory -->
- <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
- <property name="configLocation">
- <value>classpath:hibernate.cfg.xml</value>
- </property>
- </bean>
- <!-- 配置事务管理器 -->
- <!-- 配置事务管理器bean,使用HibernateTransactionManager事务管理器 -->
- <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
- <property name="sessionFactory">
- <ref bean="sessionFactory"/>
- </property>
- </bean>
- <!-- 配置事务的传播特性 -->
- <!-- 配置事务特性,配置add,delete,update开始的方法,事务传播特性为required -->
- <tx:advice id="txAdvice" transaction-manager="transactionManager">
- <tx:attributes>
- <tx:method name="add*" propagation="REQUIRED"/>
- <tx:method name="delete*" propagation="REQUIRED"/>
- <tx:method name="modify*" propagation="REQUIRED"/>
- <tx:method name="*" read-only="true"/>
- </tx:attributes>
- </tx:advice>
- <!-- 那些类的哪些方法参与事务 -->
- <!--
- <aop:config>
- <aop:advisor pointcut="execution(* com.oa.manager.*.*(..))" advice-ref="txAdvice"/>
- </aop:config>
- -->
- <!-- 配置那些类的方法进行事务管理,当前com.oa.manager包中的子包, 类中所有方法需要,还需要参考tx:advice的设置 -->
- <aop:config>
- <aop:pointcut id="allManageMethod" expression="execution(* com.oa.manager.*.*(..))" />
- <aop:advisor pointcut-ref="allManageMethod" advice-ref="txAdvice"/>
- </aop:config>
- <!-- 那些类的哪些方法参与事务 -->
- <!--
- <aop:config>
- <aop:advisor pointcut="execution(* com.oa.manager.*.*(..))" advice-ref="txAdvice"/>
- </aop:config>
- -->
- </beans>
![点击查看原始大小图片](https://static.oschina.net/uploads/img/201710/18111027_dv13.png)
![点击查看原始大小图片](https://static.oschina.net/uploads/img/201710/18111027_7Ppt.png)