Struts2.3 spring3.1 hibernate4.0.1 搭建SSH框架
更新时间:2023-08-29 00:40:01 阅读量: 教育文库 文档下载
Struts2.3+spring3.1+hibernate4.0.1 搭建SSH框架 所谓的框架:就是把一些常用的功能封装好,省去重复的开发;
损失惨重啊,一个不小心,把硬盘分区表丢了,以前的数据全丢了,重头来,做个框架出来,留着以后用吧。
预计的功能:
1. 用户管理
2. 组织机构管理
3. 模块管理
4. 权限管理
5. 工作流,jbpm,
6. cxf服务
7. oscache缓存
struts
(一) jar包
1. xwork-core-2.3.1.1.jar
2. struts2-json-plugin-2.3.1.1.jar
3. struts2-core-2.3.1.1.jar
4. struts2-convention-plugin-2.3.1.1.jar
5. struts2-config-browser-plugin-2.3.1.1.jar
6. ognl-3.0.3.jar
7. javassist-3.11.0.GA.jar
8. freemarker-2.3.18.jar
9. commons-logging-api-1.1.jar
10. commons-lang-2.5.jar
11. commons-io-2.0.1.jar
12. commons-fileupload-1.2.2.jar
13. asm-commons-3.3.jar
14. asm-3.3.jar
说明:
struts2-convention-plugin-2.3.1.1.jar为struts零配置所需的包;
struts2-config-browser-plugin-2.3.1.1.jar为struts协助开发需要的包:可以输入
http://127.0.0.1:8686/config-browser/actionNames.action查看系统所有已经存在的action,配置不正确就可以在这里看出来;
freemarker-2.3.18.jar:模板需要的支持包;
struts2-json-plugin-2.3.1.1.jar:json插件包
(二) 配置文件
/src/default.properties
web.xml
(三) 测试
/struts/TestAction.java
/src/struts.xml
/web/test-content/test1.jsp
以上是有配置文件的测试,以下是无配置action测试
struts2-convention 测试、JSON返回测试:
Freemarker返回测试:
spring + hibernate
(一) jar包
增加spring 和Hibernate让我小折腾了一下,既然是新配置框架,就全用最新的,Hibernate我用的4.x,Spring 用的是3.1 ;Hibernate4.x的包是加进去了,但数据源配置等,还是用的3.x的,所以,狂报错,最后把hibernate3改成hibernate4就可以了,具体有两个地方需要调整:
第一个就是:
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
第二个:
<bean id="transactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager" 完整配置文件,下面会贴出来。
Hibernate的jar包还是差不多,把hibernate-release-4.0.1.Final\lib\required目录的jar 包,还有c3p0加进去;
spring就稍麻烦点:
org.springframework.aop-3.1.0.RELEASE.jar
org.springframework.asm-3.1.0.RELEASE.jar
org.springframework.aspects-3.1.0.RELEASE.jar
org.springframework.beans-3.1.0.RELEASE.jar
org.springframework.context-3.1.0.RELEASE.jar
org.springframework.core-3.1.0.RELEASE.jar
org.springframework.expression-3.1.0.RELEASE.jar
org.springframework.instrument-3.1.0.RELEASE.jar
org.springframework.jdbc-3.1.0.RELEASE.jar
org.springframework.jms-3.1.0.RELEASE.jar
org.springframework.orm-3.1.0.RELEASE.jar
org.springframework.oxm-3.1.0.RELEASE.jar
org.springframework.transaction-3.1.0.RELEASE.jar
org.springframework.web-3.1.0.RELEASE.jar
另外还有
ojdbc14.jar -- oracle数据库驱动
mysql-connector-java-5.1.8-bin.jar -- mysql驱动
aopalliance-1.0.jar
aspectjweaver.jar
asm-commons-3.3.jar
及spring测试需要的:
org.springframework.test-3.1.0.RELEASE.jar
可能还缺包,不过小事,这个时候缺包会有明确的提示的:一般都是NoClassDefFoundError: XXX按名称添加就可以了,详细稍后上传;
(一) Spring配置文件:
<property name="location"> <value>classpath:com/gwtjs/config/hibernate.properties</value> </property> </bean> <bean id="dataSource" class="http://www.77cn.com.cnboPooledDataSource" destroy-method="close"> <!-- 安全的路径 jdbc:mysql://127.0.0.1:3306/va66?autoReconnect=true&useUnicode=true&characterEncoding =utf-8&mysqlEncoding=utf8 --> <property name="jdbcUrl" value="${hibernate.connection.url}" /> <property name="driverClass" value="${hibernate.connection.driver_class}" /> <property name="user" value="${http://www.77cn.com.cnername}" /> <property name="password" value="${hibernate.connection.password}" /> <property name="acquireIncrement" value="${c3p0.acquireIncrement}" /> <property name="initialPoolSize" value="${c3p0.initialPoolSize}" /> <property name="minPoolSize" value="${c3p0.minPoolSize}" /> <property name="maxPoolSize" value="${c3p0.maxPoolSize}" /> <property name="maxStatements" value="${c3p0.maxStatements}" /> <property name="numHelperThreads" value="${c3p0.numHelperThreads}" /> <property name="maxIdleTime" value="${c3p0.maxIdleTime}" /> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"> <property name="dataSource">
<ref local="dataSource" /> </prop
erty> <!--<property name="mappingResources"> <list> <value>com/gwtjs/model/ACL.hbm.xml</value> </list> </property> --><property name="hibernateProperties"> <props> <prop key="hibernate.dialect">${hibernate.dialect}</prop> <prop key="hibernate.show_sql">${hibernate.show_sql}</prop> <prop key="hibernate.generate_statistics">true</prop> <prop key="hibernate.connection.release_mode">auto</prop> <prop key="hibernate.autoReconnect">true</prop> <prop key="http://www.77cn.com.cne_sql_comments">false</prop> <prop key="http://www.77cn.com.cne_reflection_optimizer">true</prop> <prop key="hibernate.hbm2ddl.auto">update</prop> <prop key="hibernate.format_sql">${hibernate.format_sql}</prop> </props> </property> </bean> <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager"
p:sessionFactory-ref="sessionFactory" /> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="*" no-rollback-for="http://www.77cn.com.cnng.Throwable" /> <!-- <tx:method name="*" read-only="true" /> --> </tx:attributes> </tx:advice> <aop:config proxy-target-class="true"> <aop:advisor pointcut="execution(* com.gwtjs.dao.impl.*.*(..))" advice-ref="txAdvice" /> </aop:config> <context:annotation-config /> <context:component-scan base-package="com.gwtjs" /> </beans> hibernate.properties ###################### ### Query Language ### ###################### ## define query language constants / function names hibernate.query.substitutions yes 'Y', no 'N' hibernate.show_sql true ## select the classic query parser #hibernate.query.factory_class org.hibernate.hql.classic.ClassicQueryTranslatorFactory ## MySQL
hibernate.dialect org.hibernate.dialect.MySQLDialect hibernate.connection.driver_class com.mysql.jdbc.Driver hibernate.connection.url jdbc\:mysql\://127.0.0.1\:3306/NewTest http://www.77cn.com.cnername root hibernate.connection.password 860748 ## Oracle ## hibernate.dialect org.hibernate.dialect.OracleDialect ## hibernate.connection.driver_class oracle.jdbc.driver.OracleDriver ## http://www.77cn.com.cnername FoundationDB ## hibernate.connection.password FoundationDBPwd ## hibernate.connection.url jdbc:oracle:thin:@localhost:1521:orcl ## set the maximum depth of the outer join fetch tree hibernate.connection.pool_size 1 hibernate.proxool.pool_alias pool1 hibernate.format_sql false ## add comments to the generated SQL http://www.77cn.com.cne_sql_comments true ## set the maximum depth of the outer join fetch tree hibernate.max_fetch_depth 1 hibernate.jdbc.batch_versioned_data true http://www.77cn.com.cne_streams_for_binary true hibernate.cache.region_prefix hibernate.test hibernate.cache.provider_class org.hibernate.cache.HashtableCacheProvider
(二) web.xml
- 1hibernate与struts、spring三大框架整合中web-xml的使用介绍
- 2Eclipse+Struts2+Spring+MyBatis环境搭建
- 3MyEclipse下SSH2框架搭建
- 4简单MyEclipse搭建SSH框架登录实例
- 5MyEclipse下SSH2框架搭建
- 6spring+hibernate+struts2应用mysql数据库乱码问题
- 7spring+hibernate+struts2应用mysql数据库乱码问题
- 8最新版本Struts2.3.12+Spring3.2.2+Hibernate4.2
- 9第6章 Struts2、Hibernate和Spring整合应用 课堂 精简
- 10第6章 Struts2、Hibernate和Spring整合应用 课堂 精简
- exercise2
- 铅锌矿详查地质设计 - 图文
- 厨余垃圾、餐厨垃圾堆肥系统设计方案
- 陈明珠开题报告
- 化工原理精选例题
- 政府形象宣传册营销案例
- 小学一至三年级语文阅读专项练习题
- 2014.民诉 期末考试 复习题
- 巅峰智业 - 做好顶层设计对建设城市的重要意义
- (三起)冀教版三年级英语上册Unit4 Lesson24练习题及答案
- 2017年实心轮胎现状及发展趋势分析(目录)
- 基于GIS的农用地定级技术研究定稿
- 2017-2022年中国医疗保健市场调查与市场前景预测报告(目录) - 图文
- 作业
- OFDM技术仿真(MATLAB代码) - 图文
- Android工程师笔试题及答案
- 生命密码联合密码
- 空间地上权若干法律问题探究
- 江苏学业水平测试《机械基础》模拟试题
- 选课走班实施方案
- 搭建
- hibernate
- 框架
- Struts
- spring
- 2.3
- 3.1
- 4.0
- SSH
- 东师《中外学前教育史》17春在线作业1
- XX小学防校园欺凌工作方案
- 加拿大的商务礼仪
- 2020年度基层党支部书记党建工作述职报告(完整材料).docx
- 组织内部关系与外部关系的协调
- 南宁计算机耗材价格清单
- 食品护色剂与漂白剂1
- OEM-ODM采购合同范本
- 公交都市考核评价指标体系
- 公路桥涵施工技术规范—新老规范对比
- 国际商法,第三章 国际货物买卖法
- 华梁中学八年级英语下册 Unit 8 Beautiful Clothes Topic 1知识点汇编 仁爱版
- 多边形与平行四边形
- 如何除去试剂中的杂质
- 热血江湖传升天3转职怎么做 升天密境4层掉落哪些物品
- 世茂物业作业文件
- 厦门市2013—2014学年(上)高一质量检测化学试题及参考答案
- 水利工程建设项目开工申请报告表
- “十三五”规划重点-体检中心项目建议书(立项报告)
- 广播电视基础知识