网站大量收购闲置独家精品文档,联系QQ:2885784924

Struts2+Spring4+Hibernate4整合(注释版).docx

  1. 1、本文档共9页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Struts2Spring4Hibernate4整合(注释版)

Struts2 + Spring 4 + Hibernate 4整合注释版作者:唐礼飞Q Q:2720484171准备开发工具:eclipse-reporting-luna-SR2-win32(最新版也可)数据库:Microsoft SQL Server 2008 R2本次集成Struts2、Spring、Hibernate版本:struts-2.3.20spring-framework-4.1.0hibernate-release-4.3.92实施2.1创建项目2.2 创建数据库(SSH)2.3添加Struts2、Spring、Hibernate需要的jar文件到项目2.3.1Struts22.3.2Spring2.3.3Hibernate2.3.4删除同名的jar文件(保留高版本号的)2.4添加数据库Microsoft SQL Server 2008的JDBC驱动程序2.5添加DBCP数据库连接技术的jar文件到项目2.6添加其它需要的jar文件根据项目的需要进行添加。2.7创建Hibernate配置文件hibernate.cfg.xml2.7.1创建hibernate.cfg.xml文件?xmlversion=1.0encoding=utf-8?!DOCTYPEhibernate-configurationPUBLIC-//Hibernate/Hibernate Configuration DTD 3.0//EN/dtd/hibernate-configuration-3.0.dtdhibernate-configuration/hibernate-configuration2.7.2添加Hibernate初始化参数信息session-factory!-- 显示SQL语句 --propertyname=show_sqltrue/property!-- 格式化SQL语句 --propertyname=format_sqltrue/property!-- 根据实体类修改数据库 --propertyname=hbm2ddl.autocreate-drop/property/session-factory2.8创建项目配置属性文件appPperties2.8.1创建文件File—New—File输入文件名appPperties(文件扩展名必须是.properties)2.8.2添加数据库连接配置信息#Microsoft SQL Server 2008connection.driver_class=com.microsoft.sqlserver.jdbc.SQLServerDriverconnection.url=jdbc:sqlserver://localhost:1433;DatabaseName=SSHconnection.username=saconnection.password=1232.9创建Spring配置文件applicationContext.xml?xmlversion=1.0encoding=UTF-8?beansxmlns=/schema/beansxmlns:xsi=/2001/XMLSchema-instancexmlns:context=/schema/contextxsi:schemaLocation=/schema/beans/schema/beans/spring-beans.xsd/schema/context/schema/context/spring-context.xsd/beans2.10修改applicationContext.xml文件添加项目配置属性文件!-- 引入项目配置属性文件 --context:property-placeholderlocation=classpath:appPperties/2.11修改项目web.xml配置文件,添加Spring监听!-- 添加Spring框架配置参数 --context-paramparam-namecontextConfigLocation/param-nameparam-valueclasspath:applicationContext.xml/param-value/context-param!-- 添加Spring监听 --listenerlistener-classorg.springframework.web.context.ContextLoaderListener/listener-class/listener2.12整合Spring和Hibernate在Spring的applicationContext.xml配置文件中添加数据源Bean和会话工厂Bean的定义。!-- 配置数据源 --beanid=dataSo

文档评论(0)

xcs88858 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

版权声明书
用户编号:8130065136000003

1亿VIP精品文档

相关文档