ssh整合步骤之一(搭建环境)
ssh整合主要可以分为3个步骤:搭建环境、设计架构、实现逻辑
以下是搭建环境的步骤
1、导入jar包
导入ssh基本jar包
2、导入ssh配置文件。
包括(struts.xml hibernate.cfg.xml `````.hbm.xml applicationContext.xml jdbc/properties)
3、整合strut与spring
1)web.xml
在web.xml中加上以下代码
<context-param><param-name>contextConfigLocation</param-name><param-value>classpath:applicationContext.xml</param-value>
</context-param>
<listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener><!-- 配置Spring的用于解决懒加载问题的过滤器 --><filter><filter-name>OpenSessionInViewFilter</filter-name><filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class></filter><filter-mapping><filter-name>OpenSessionInViewFilter</filter-name><url-pattern>*.action</url-pattern></filter-mapping>
4、整合spring与hibernate
1)在applicationContext.xml中加上以下代码:
<context:component-scan base-package="com.njupt"></context:component-scan><context:property-placeholder location="classpath:jdbc.properties" /><bean id="sessionFactory"class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"><!-- 指定hibernate的配置文件位置 --><property name="configLocation" value="classpath:hibernate.cfg.xml"></property><!-- 配置c3p0数据库连接池 --><property name="dataSource"><bean class="com.mchange.v2.c3p0.ComboPooledDataSource"><!-- 数据连接信息 --><property name="jdbcUrl" value="${jdbcUrl}"></property><property name="driverClass" value="${driverClass}"></property><property name="user" value="${user}"></property><property name="password" value="${password}"></property><!-- 其他配置 --><!--初始化时获取三个连接,取值应在minPoolSize与maxPoolSize之间。Default: 3 --><property name="initialPoolSize" value="3"></property><!--连接池中保留的最小连接数。Default: 3 --><property name="minPoolSize" value="3"></property><!--连接池中保留的最大连接数。Default: 15 --><property name="maxPoolSize" value="5"></property><!--当连接池中的连接耗尽的时候c3p0一次同时获取的连接数。Default: 3 --><property name="acquireIncrement" value="3"></property><!--控制数据源内加载的PreparedStatements数量。如果maxStatements与maxStatementsPerConnection均为0,则缓存被关闭。Default:0--><property name="maxStatements" value="8"></property><!--maxStatementsPerConnection定义了连接池内单个连接所拥有的最大缓存statements数。Default: 0--><property name="maxStatementsPerConnection" value="5"></property><!--最大空闲时间,1800秒内未使用则连接被丢弃。若为0则永不丢弃。Default: 0 --><property name="maxIdleTime" value="1800"></property></bean></property></bean><bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"><property name="sessionFactory" ref="sessionFactory"></property></bean><tx:annotation-driven transaction-manager="txManager"/>
到这里ssh就整合完了,以下是一些方便使用的功能:
1)hibernate.cfg.xml中贴上
<property name="hbm2ddl.auto">update</property>
以上代码完成自动建表功能
ssh整合步骤之一(搭建环境)相关推荐
- ssh整合之四单独搭建struts的运行环境
1.导入struts的基本jar包 2.在web.xml中配置我们struts的核心控制器StrutsPrepareAndExecuteFilter <?xml version="1. ...
- ssh整合步骤之二(架构设计)
1.新建一个com.njupt.action的包,再在里面李建一个UserAction,然后ctrl + c ,ctrl + v(6次).这时候便完成的一个三层的 体系架构,如下图所示:
- 我的世界curseforge整合包服务器搭建
我的世界curseforge整合包服务器搭建 环境 开始搭建 1.下载整合包服务端 2.启动与配置 配置 资源链接 环境 环境 版本 服务器 阿里云Ubuntu18 2核4G minecraft主体 ...
- SSM(Spring+SpringMVC+Mybatis)框架环境搭建(整合步骤)(一)
SSM(Spring+SpringMVC+Mybatis)框架环境搭建(整合步骤)(一) 1. 前言 最近在写毕设过程中,重新梳理了一遍SSM框架,特此记录一下. 附上源码:https://gitee ...
- maven环境下SSH整合
目录 Maven环境下SSH整合 1 目录结构: 1 1. 导入jar包 2 1.1搭建maven环境 2 1.2配置pom.xml文件 2 1.2.1 pom.xml 2 2. 搭建struts2环 ...
- 搭建环境_maven: 搭建工程: ssm整合: 搭建测试:
2019独角兽企业重金招聘Python工程师标准>>> 搭建环境_maven: 搭建工程: ssm整合: 搭建测试: 搭建环境问题解决: 转载于:https://my.oschina ...
- nginx整合php+lua+oracle环境搭建
nginx整合php+lua+oracle环境搭建 标签: nginxluaoraclephplinux 2014-09-25 10:39 1473人阅读 评论(0) 收藏 举报 分类: 技术( ...
- ssh整合学习(1)
Hibernate框架 1 hibernate核心配置文件 (0)orm思想 -对象关系映射 (1)数据库信息 (2)hibernate信息 (3)映射配置 (4)hibernate核心配置文件 -如 ...
- [Laravel] mac下通过 homestead 搭建环境 到运行项目
seven_Android 关注 2017.07.03 21:33* 字数 2240 阅读 3464评论 10喜欢 9 之前学习过一段时间的 Laravel ,换 mac 后一直没空做相关的事情,而且 ...
最新文章
- spring 事务管理之只读事务@Transactional(readOnly = true)
- python寻找1000以内的阿姆斯特朗数
- Java企业介绍,Hunson 介绍
- VS2008SP1使用入门
- 建模与计算机应用,数学建模与计算机应用竞赛.doc
- 我的CV实习工作总结
- innobackupex 简单使用笔记
- 排列组合 C语言函数,排列组合c怎么算 计算方法是什么
- 法国科学家大脑计算机,最新发现:人类大脑的“人性基因”正加速进化
- 【动态规划】字符串编辑距离(Levenshtein距离)算法
- coco数据集分割可视化格式转换
- Windows10系统部分软件出现中文乱码解决方法
- 多商家商城系统有哪些功能
- ggplot2-为可视化建模2
- PLC之六部十层电梯整体框架
- MIPS 五级流水线
- jsp+ssm计算机毕业设计游戏网站设计【附源码】
- 【CSS.DIV】HTMLli标签
- 美国访问学者生活需要注意的七大事项
- 谷歌浏览器正在等待可用的套接字