1.spring

1.1 jar包

1.2 spring.xml

<?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:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"> <!--包扫描注解-->
<context:component-scan base-package="cn.getword" />
<!--配置spring AOP扫描注解 如果没有自定义的通知类,可以不配-->
<aop:aspectj-autoproxy />
</beans>

2. 整合hibernate

2.1 jar包

(1)required

(2)c3p0

(3)驱动

2.2 spring配置

<?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:context="http://www.springframework.org/schema/context"
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.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"> <!--包扫描注解-->
<context:component-scan base-package="cn.getword" />
<!--配置spring AOP扫描注解 如果没有自定义的通知类,可以不配-->
<aop:aspectj-autoproxy /> <!--hibernate相关-->
<!--c3p0数据源-->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/db_ssh?characterEncoding=utf-8" />
<property name="driverClass" value="com.mysql.jdbc.Driver" />
<property name="user" value="root" />
<property name="password" value="123" />
</bean>
<!--hibernate的sessionFactory spring的ORM提供的-->
<bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<!--hibernate可选配置-->
<property name="hibernateProperties">
<props>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
</props>
</property>
<!--实体类的包路径-->
<property name="packagesToScan">
<array>
<value>cn.getword.domain</value>
</array>
</property>
</bean> <!--spring提供的hibernate事务管理器 声明式事务-->
<bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<!--配置事务注解驱动-->
<tx:annotation-driven transaction-manager="transactionManager" />
</beans>

spring.xml

3. 整合struts2

3.1 jar包

min:

注解需要:

struts-convention-plugin.jar

asm.jar

asm-commons.jar

整合spring:

end

spring整合struts2和hibernate的更多相关文章

  1. 一 SSH整合:Spring整合Struts2的两种方式,struts.xml管理Action&Bean管理Action

    SSH回顾 1 引入jar包 Struts2的jar包 D:\Struts2\struts-2.3.35\apps\struts2-blank\WEB-INF\lib  开发基本包 Struts2有一 ...

  2. Struts2的使用以及Spring整合Struts2

    一.如何单独使用Struts2 (1)引入struts2的jar包 commons-fileupload-1.2.1.jar freemarker-2.3.15.jar ognl-2.7.3.jar ...

  3. spring整合springmvc和hibernate

    上篇文章使用maven搭建了web环境,这篇来记录下如何使用spring整合springmvc和hibernate,亦即spring+springmvc+hibernate框架整合. 第一步:首先配置 ...

  4. Spring整合Struts2框架的第二种方式(Action由Spring框架来创建)(推荐大家来使用的)

    1. spring整合struts的基本操作见我的博文:https://www.cnblogs.com/wyhluckdog/p/10140588.html,这里面将spring与struts2框架整 ...

  5. Spring整合Struts2框架的第一种方式(Action由Struts2框架来创建)。在我的上一篇博文中介绍的通过web工厂的方式获取servcie的方法因为太麻烦,所以开发的时候不会使用。

    1. spring整合struts的基本操作见我的上一篇博文:https://www.cnblogs.com/wyhluckdog/p/10140588.html,这里面将spring与struts2 ...

  6. Spring框架学习(5)spring整合struts2

    内容源自:spring整合struts2 一.spring框架对struts等表现层框架的整合原理 : 使用spring的ioc容器管理struts中用于处理请求的Action 将Action配置成i ...

  7. Spring整合Struts2的方法

    一.基本支持 通常我们整合Spring和struts2的目的是让Spring来管理struts2的控制器.也就是说把Action交由Spring来管理,利用IOC的特性把Action注入到业务逻辑中. ...

  8. Spring整合Struts2,Hibernate的xml方式

    作为一个学习中的码农,一直学习才是我们的常态,所以最近学习了SSH(Spring,Struts2,Hibernate)整合,数据库用的MySQL. 写了一个简单的例子,用的工具是IntelliJ Id ...

  9. spring整合mybatis、hibernate、logback配置

    Spring整合配置Mybatis 1.配置数据源(连接数据库最基本的属性配置,如数据库url,账号,密码,和数据库驱动等最基本参数配置) <!-- 导入properties配置文件 --> ...

随机推荐

  1. const 与define 创建符号常量的 用法与区别

    一.define 的用法: 在c语言中我经常会看到 :#define  PI  12 ,这是创建了一个符号常量,这里面要注意没有那个等于号“=”: 二.const 的用法: 1.const 也可以来创 ...

  2. Spring boot整合Mongodb

    最近的项目用了Mongodb,网上的用法大多都是七零八落的没有一个统一性,自己大概整理了下,项目中的相关配置就不叙述了,由于spring boot的快捷开发方式,所以spring boot项目中要使用 ...

  3. [ActionScript 3.0] 如何控制加载swf动画的播放与暂停

    此方法适用于用as 1.0或者as2.0以及as3.0编译的swf,因为as1.0和as2.0编译的swf是AVM1Movie类型,因此需要通过类ForcibleLoader.as将其转换为versi ...

  4. [Swift实际操作]八、实用进阶-(9)Swift中的链表LinkedList详解

    链表是一种物理存储单元上的非连续.非顺序的存储结构,数据元素的逻辑顺序是通过链表中的指针连接次序实现的.相比于线性表的顺序结构,链表比较方便插入和删除操作.本文将讲解如何模拟一个链表. //链表的节点 ...

  5. excel的公式:查找匹配某个值的单元格--MATCH()

    这个非常简单,没啥说的,D1位置是显示这个值所在的行数,如果是跨表,就在匹配区域前面加上  sheetName!

  6. 程序设计中的dry原则

    DRY:dont repeat yourself 假设一个逻辑(代码块)会重复两次或者以上,应该写成函数被调用 为什么呢,实际上,我们处处可见重复性的代码.这除了增加工作量之外,还会增加维护难度. d ...

  7. Eclipse MarketPlace 打不开,对话框闪退

    原文地址: https://blog.csdn.net/wonder_boy869/article/details/81031222 Eclipse的版本更新到了4.8.0(photon版),点击he ...

  8. js 常用js正则表达式大全

    一.校验数字的js正则表达式   1 数字:^[0-9]*$     2 n位的数字:^d{n}$     3 至少n位的数字:^d{n,}$     4 m-n位的数字:^d{m,n}$     5 ...

  9. [原创]Redis 持久化说明及配置

    目录 参考链接 介绍 RDB 持久化 优点 缺点 相关配置参数 AOF 持久化 优点 缺点 相关配置参数 参考链接 持久化 Redis命令参考 介绍 Redis 运行时数据保存在内存中, 一旦重启则数 ...

  10. 高阶篇:4.4)FMEA手册的疑问与不足(个人观点)

    本章目的:如题,述说FMEA手册第四版的疑问与不足. 1.前言 作者接触FMEA,并真正将其作为可靠性设计方法,也是在近几年的时候,所以不能说算是一个FMEA专家吧. 但作者也有一些自己的优势,就是自 ...