zoukankan      html  css  js  c++  java
  • 框架集成

    Struts2+Spring2.5+Hibernate3.3整合开发
    先整合Spring2.5+Hibernate3.3

    hibernate核心安装包下的(下载路径:http://www.hibernate.org/),点击"Hibernate Core" 右边的"DownLoads"
    hibernamte3.jar
    lib\bvtecode\calib\jobernate-cglib-repack-2.1_3.jar
    lib\required\*.jar
    hibernate注解安装包下的(下载路径:www.hibernate.org,点击"Hibernate Annotations"右边的"DownLoads")
    hibernate-annotations.jar
    lib\ejb3-persistence.jar、hibernate-commons-annotations.jar
    Hibernate针对JPA的实现包(下载路径:www.hibernate.org,点击"Hibernate Entitvmanager" 右边的"Downloads")
    hibernate-entitymanager.jar
    lib\test\log4j.jar、slf-log4j12.jar

    首先 File--> New --> Web Project-->输入Project Name:后点击Finish
    拷贝Hibernamte的jar包同样粘贴到WebRoot下WEB-INF下lib下
    拷贝Spring的jar包同样粘贴到WebRoot下WEB-INF下lib下
    首先新建一个xml文件
    src-->New-->New XML File 在File name:输入名称随便取
    拷贝spring的配置模板
    之后 <context:component-scan base-package=""/>代表要扫瞄的包
    集成sessionFactory

    <bean>配置数据源</bean>

    <bean id="sessionFactory" class="org.springframeword.orm.hibernate3.LocalSessionFactoryBean"
    <property name="dataSource" ref="dataSource"/>
    <property name="mappingResources">
      <list>
      <value>cn/itcast/bean/buyer.hbm.xml</value>
      </list>
    </property>
    <property name="hibernateProperties">
    <value>
        hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
        hibernate.hbm2ddl.auto=update
        hibernate.show_sql=false
        hibernate.format_sql=false
    </value>
    </property>
    </bean>

    <bean>配置事物管理器</bean>
    <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
       <property name="sessionFactory" ref="sessionFactory"/>注入sessionFactory
    </bean>
    spring的事务配置
    注解的方式和XML两种方式
    <tx:annotation-driven transaction-manager="txManager"/>指定事务管理器

    配置文件 结束


    New-->Class-->所要放在哪个包下面 以及新建 枚举类型如性别
    在新建的这个表下面建一个xml文件
    Hibernate的映射文件

  • 相关阅读:
    Nginx 模块开发(1)—— 一个稍稍能说明问题模块开发 Step By Step 过程
    nginx上传模块—nginx upload module-
    解决nginx上传模块nginx_upload_module传递GET参数
    nginx upload module的使用
    Nginx Upload Module 上传模块
    产品需求分析神器:KANO模型分析法
    SpringBoot @ConditionalOnBean、@ConditionalOnMissingBean注解源码分析与示例
    BAT、网易、京东等如何做大数据风控的?
    springboot 2.x 集成 drools 7.x
    Drools介绍与使用
  • 原文地址:https://www.cnblogs.com/wuhuisheng/p/2096957.html
Copyright © 2011-2022 走看看