一、导包

antlr-2.7.7.jar
asm-3.3.jar
asm-commons-3.3.jar
asm-tree-3.3.jar
com.springsource.com.mchange.v2.c3p0-0.9.1.2.jar
com.springsource.org.aopalliance-1.0.0.jar
com.springsource.org.apache.commons.logging-1.1.1.jar
com.springsource.org.apache.log4j-1.2.15.jar
com.springsource.org.aspectj.weaver-1.6.8.RELEASE.jar
commons-fileupload-1.3.1.jar
commons-io-2.2.jar
commons-lang3-3.2.jar
dom4j-1.6.1.jar
freemarker-2.3.22.jar
geronimo-jta_1.1_spec-1.1.1.jar
hibernate-commons-annotations-5.0.1.Final.jar
hibernate-core-5.0.7.Final.jar
hibernate-jpa-2.1-api-1.0.0.Final.jar
jandex-2.0.0.Final.jar
javassist-3.18.1-GA.jar
jboss-logging-3.3.0.Final.jar
jstl-1.2.jar
log4j-api-2.2.jar
log4j-core-2.2.jar
mysql-connector-java-5.1.7-bin.jar
ognl-3.0.6.jar
spring-aop-4.2.4.RELEASE.jar
spring-aspects-4.2.4.RELEASE.jar
spring-beans-4.2.4.RELEASE.jar
spring-context-4.2.4.RELEASE.jar
spring-core-4.2.4.RELEASE.jar
spring-expression-4.2.4.RELEASE.jar
spring-jdbc-4.2.4.RELEASE.jar
spring-orm-4.2.4.RELEASE.jar
spring-test-4.2.4.RELEASE.jar
spring-tx-4.2.4.RELEASE.jar
spring-web-4.2.4.RELEASE.jar
standard.jar
struts2-core-2.3.24.jar
struts2-spring-plugin-2.3.24.jar
xwork-core-2.3.24.jar

二、spring与hibernate整合

  hibernate.cfg.xml

 1 <?xml version='1.0' encoding='utf-8'?>
2 <!DOCTYPE hibernate-configuration PUBLIC
3 "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
4 "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
5
6 <hibernate-configuration>
7 <session-factory>
8 <!-- Mysql数据库方言 -->
9 <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
10 <!-- 显示sql语句 -->
11 <property name="show_sql">true</property>
12
13 <!-- 引入映射文件 -->
14 <mapping resource="com/tx/model/User.hbm.xml"/>
15 </session-factory>
16 </hibernate-configuration>

  ApplicationContext.xml

 1 <?xml version="1.0" encoding="UTF-8"?>
2 <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3 xmlns="http://www.springframework.org/schema/beans"
4 xmlns:context="http://www.springframework.org/schema/context"
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/beans
8 http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
9 http://www.springframework.org/schema/context
10 http://www.springframework.org/schema/context/spring-context-4.2.xsd
11 http://www.springframework.org/schema/aop
12 http://www.springframework.org/schema/aop/spring-aop-4.2.xsd
13 http://www.springframework.org/schema/tx
14 http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
15 ">
16
17 <!-- 读取db.properties文件 -->
18 <context:property-placeholder location="classpath:db.properties"/>
19 <!-- 配置数据源 -->
20 <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
21 <property name="driverClass" value="${jdbc.driverClass}"></property>
22 <property name="jdbcUrl" value="${jdbc.url}"></property>
23 <property name="user" value="${jdbc.user}"></property>
24 <property name="password" value="${jdbc.password}"></property>
25 </bean>
26
27 <!-- 用spring orm包整合sessionFactory -->
28 <bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
29 <!-- 注入数据源 -->
30 <property name="dataSource" ref="dataSource"></property>
31 <!-- 加载hibernate核心配置文件 -->
32 <property name="configLocation" value="classpath:hibernate.cfg.xml"></property>
33 </bean>
34
35 <!-- 用spring rom的hibernate事务管理器 -->
36 <bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
37 <!-- 注入sessionFactory -->
38 <property name="sessionFactory" ref="sessionFactory"></property>
39 </bean>
40
41 <!-- 配置 -->
42 <tx:advice id="txAdvice" transaction-manager="transactionManager">
43 <tx:attributes>
44 <tx:method name="save*" propagation="REQUIRED"/>
45 <tx:method name="update*" propagation="REQUIRED"/>
46 <tx:method name="delete*" propagation="REQUIRED"/>
47 <tx:method name="query*" read-only="true"/>
48 </tx:attributes>
49 </tx:advice>
50
51 <aop:config>
52 <!-- 配置切点 -->
53 <aop:pointcut expression="execution(* com.tx.service..*.*(..))" id="mycut"/>
54 <aop:advisor advice-ref="txAdvice" pointcut-ref="mycut"/>
55 </aop:config>
56
57 <!-- ==============以上为spring与hibernate的整合配置====================== -->
58 <bean id="userAction" class="com.tx.action.UserAction" scope="prototype">
59 <property name="userService" ref="userService"></property>
60 </bean>
61 <!-- ==============以上为spring与struts的整合============================ -->
62 <bean id="userDao" class="com.tx.dao.impl.UserDaoImpl">
63 <property name="sessionFactory" ref="sessionFactory"></property>
64 </bean>
65 <bean id="userService" class="com.tx.service.impl.UserServiceImpl">
66 <property name="userDao" ref="userDao"></property>
67 </bean>
68 </beans>

三、spring与struts2整合

  struts.xml

 1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE struts PUBLIC
3 "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
4 "http://struts.apache.org/dtds/struts-2.3.dtd">
5
6 <struts>
7 <!-- # struts.objectFactory = spring 将action的创建交给spring容器
8 struts.objectFactory.spring.autoWire = name spring负责装配Action依赖属性
9 -->
10 <!-- <constant name="struts.objectFactory" value="spring"></constant> -->
11
12 <package name="user" namespace="/" extends="struts-default" >
13 <action name="userAction_*" class="userAction" method="{1}">
14 <result name="success">/success.jsp</result>
15 </action>
16 </package>
17 </struts>
18

Struts2+Spring4.2+Hibernate4.3整合的更多相关文章

  1. Spring4 SpringMVC Hibernate4 Freemaker 整合样例

    更正改动(2014-05-30 13:47:22):有的IDE中web.xml会报这个错: cvc-complex-type.2.4.a: Invalid content was found star ...

  2. spring4.x hibernate4.x 整合 ehcache 注解 annotate

    [From] http://my.oschina.net/alexgaoyh/blog/348188

  3. Struts2+Spring4+Hibernate4整合超详细教程

    Struts2.Spring4.Hibernate4整合 超详细教程 Struts2.Spring4.Hibernate4整合实例-下载 项目目的: 整合使用最新版本的三大框架(即Struts2.Sp ...

  4. 最新版本的Struts2+Spring4+Hibernate4三大框架整合(截止2014-10-15,提供源码下载)

    一. 项目名称:S2316S411H436 项目原型:Struts2.3.16 + Spring4.1.1 + Hibernate4.3.6 + Quartz2.2.1 源代码下载地址: 基本版:ht ...

  5. Maven+struts2+spring4+hibernate4的环境搭建

    搭建Maven+struts2+spring4+hibernate4其实并不难!但开始弄的时候还是费了我好大的力气,老是出现这样那样的错误!好了,废话不多说,开始搭建开发环境. 一.Myeclipse ...

  6. 基于Struts2,Spring4,Hibernate4框架的系统架构设计与示例系统实现

    笔者在大学中迷迷糊糊地度过了四年的光景,心中有那么一点目标,但总感觉找不到发力的方向. 在四年间,尝试写过代码结构糟糕,没有意义的课程设计,尝试捣鼓过Android开发,尝试探索过软件工程在实际开发中 ...

  7. 使用Maven搭建Struts2+Spring3+Hibernate4的整合开发环境

    做了三年多的JavaEE开发了,在平时的JavaEE开发中,为了能够用最快的速度开发项目,一般都会选择使用Struts2,SpringMVC,Spring,Hibernate,MyBatis这些开源框 ...

  8. SSH(Struts2+Spring4+Hibernate4)框架教程之配置篇

    SSH(Struts2+Spring4+Hibernate4)框架教程之配置篇 - 若明天不见 - 博客频道 - CSDN.NEThttp://blog.csdn.net/why_still_conf ...

  9. spring4+springmvc+springdataJPA+hibernate4+Junit4整合懒加载问题

    文章目录 技术交流 #摘要 本文主要是为了解决"spring4+springmvc+springdataJPA+hibernate4+junit4整合",注解了OneToMany. ...

随机推荐

  1. wordpress建站如何用SMTP配置邮件通知

    前提条件:你已经有了企业邮箱,相关文章请看:如何开通阿里云企业邮箱免费版(点此前往) 不建议使用主机商提供的邮箱,因为换主机商是比较常见的事情,因此导致的邮箱迁移就有些麻烦了,不如一开始就选择独立的第 ...

  2. Nginx反向代理的使用

    一.Nginx的基本命令 nginx:启动 nginx nginx -t :测试配置文件是否有语法错误 nginx -s reopen:重启Nginx nginx -s reload:重新加载Ngin ...

  3. [CSP-S2019]Emiya 家今天的饭 题解

    CSP-S2 2019 D2T1 很不错的一题DP,通过这道题学到了很多. 身为一个对DP一窍不通的蒟蒻,在考场上还挣扎了1h来推式子,居然还有几次几乎推出正解,然而最后还是只能打个32分的暴搜滚粗 ...

  4. HDU - 3499 -(Dijkstra变形+枚举边)

    Recently, Shua Shua had a big quarrel with his GF. He is so upset that he decides to take a trip to ...

  5. MPI Maelstrom (Dijstra+atoi函数转换整数)

    BIT has recently taken delivery of their new supercomputer, a 32 processor Apollo Odyssey distribute ...

  6. [HGAME] Week1 Web WriteUp

    一 .Cosmos的博客 打开题目之后,首页直接给了我们提示: 版本管理工具常用的有git和svn两种,这里提示了GitHub,考虑Git信息泄露,先访问/.git/目录考虑用Githack获取泄露信 ...

  7. 使用IntersectionObserver 实现下拉加载更多

    IntersectionObserver是浏览器原生提供的构造函数,接受两个参数:callback是可见性变化时的回调函数,option是配置对象(该参数可选). <!DOCTYPE html& ...

  8. 使用HttpUrlConnection访问www.163.com遇到503问题,用设置代理加以解决

    一次我使用如下程序连接到网易,意图获取其网站的html文本: try { String urlPath = "http://www.163.com/"; URL url = new ...

  9. MyBatis源码骨架分析

    源码包分析 MyBatis 源码下载地址:https://github.com/MyBatis/MyBatis-3 MyBatis源码导入过程: 下载MyBatis的源码 检查maven的版本,必须是 ...

  10. UI中列表

    1.ul.ol.dl