zoukankan      html  css  js  c++  java
  • SSH整合

    一:导包

    1、hibernate

    hibernate/lib/required目录下所有包

    hibernate/lib/jpa目录下包

    数据库驱动包

    2、struts2

    struts-blank.war/WEB-INF/lib目录下所有包(javassist-3.18.1-GA.jar和hibernate中的一样)

    struts2整合spring的插件包(必须和spring整合的时候采用,不然会报错)

    3、spring

    基本包4+2

    整合web:web包

    整合aop:4个

    整合hibernate和事务:4个

    整合junit4测试:test包

     

    4、jstl和standard(eclipse需要导标签库,myEclipse不需要)

    二:配置

    单独配置spring容器

    创建配置文件并导入4个约束

      beans | context | aop | tx

      

     配置spring随项目启动(web.xml中)

       

    单独配置struts2

    配置struts2的主配置文件并导入struts的约束

      

    配置struts2的核心过滤器(web.xml中)

      

    单独配置hibernate

    必选

       

    可选

      

    引入实体映射文件

      

    spring和struts2整合

    导包

    spring负责创建action并组装

    UserAction.java

      

    struts.xml中配置常量

      

    struts.xml中action配置

      

    applicationContext.xml中action配置

      

    spring和hibernate整合

    整合原理:

      将sessionFactory对象交给spring容器管理

    在spring中配置sessionFactory

    applicationContext.xml配置方案一

      

    applicationContext.xml配置方案二

      

    spring和c3p0整合

    applicationContext.xml中c3p0配置

      

    配置完上面这个之后,spring和hibernate的整合配置就要有所变化了

    去掉这些

      

    填上

      

    spring整合aop事务

    准备工作

      

    xml配置

    配置通知

      

    配置织入

      

    注解配置

    开启注解事务

      

    在service类中使用注解

      类上

      

      方法上

      

    扩大session的作用范围

    为了避免使用懒加载时出现的no-session,需要扩大session的作用范围

    配置filter(web.xml中)

      

       

  • 相关阅读:
    android29
    android28
    android27
    android26
    Dynamics CRM2011 MspInstallAction failed when installing an Update Rollup
    Dynamics CRM Import Solution Attribute Display Name description is null or empty
    The service cannot be activated because it does not support ASP.NET compatibility
    IIS部署WCF报 无法读取配置节“protocolMapping”,因为它缺少节声明
    Unable to access the IIS metabase.You do not have sufficient privilege
    LM算法与非线性最小二乘问题
  • 原文地址:https://www.cnblogs.com/ms-grf/p/7449979.html
Copyright © 2011-2022 走看看