1.建立动态web工程,加入必要的jar包。

antlr-2.7.7.jar
asm-3.3.jar
asm-commons-3.3.jar
asm-tree-3.3.jar
c3p0-0.9.1.2.jar
com.springsource.net.sf.cglib-2.2.0.jar
com.springsource.org.aopalliance-1.0.0.jar
com.springsource.org.aspectj.weaver-1.6.8.RELEASE.jar
commons-fileupload-1.2.2.jar
commons-io-2.0.1.jar
commons-lang3-3.1.jar
commons-logging-1.1.1.jar
dom4j-1.6.1.jar
freemarker-2.3.19.jar
hibernate-commons-annotations-4.0.2.Final.jar
hibernate-core-4.2.4.Final.jar
hibernate-jpa-2.0-api-1.0.1.Final.jar
javassist-3.11.0.GA.jar
javassist-3.15.0-GA.jar
jboss-logging-3.1.0.GA.jar
jboss-transaction-api_1.1_spec-1.0.1.Final.jar
mchange-commons-java-0.2.10.jar
mysql-connector-java-5.1.26-bin.jar
ognl-3.0.5.jar
spring-aop-4.0.0.RELEASE.jar
spring-aspects-4.0.0.RELEASE.jar
spring-beans-4.0.0.RELEASE.jar
spring-context-4.0.0.RELEASE.jar
spring-core-4.0.0.RELEASE.jar
spring-expression-4.0.0.RELEASE.jar
spring-jdbc-4.0.0.RELEASE.jar
spring-orm-4.0.0.RELEASE.jar
spring-tx-4.0.0.RELEASE.jar
spring-web-4.0.0.RELEASE.jar //此包为spring整合到web的关键jar包
struts2-core-2.3.4.jar
struts2-spring-plugin-2.3.4.jar
xwork-core-2.3.4.jar

2. web.xml的配置

<!-- 配置spring监听器,在动态web加载时就将其配置文件一同加载 --><context-param><param-name>contextConfigLocation</param-name><!-- 将spring配置文件放入一个IOC容器 --><param-value>classpath:applicationcontext.xml</param-value></context-param><listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener><!-- struts2的配置文件,拦截所有请求,判断是否是struts2请求,若是则拦截,若不是则放行 --><filter><filter-name>struts2</filter-name><filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class></filter><filter-mapping><filter-name>struts2</filter-name><url-pattern>/*</url-pattern></filter-mapping>

3. spring整合hibernate及struts2的配置文件

  图解如下:

  

applicationcontext.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:tx="http://www.springframework.org/schema/tx"xmlns:aop="http://www.springframework.org/schema/aop"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsdhttp://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsdhttp://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd"><!-- 加载db.properties文件 --><context:property-placeholder location="classpath:db.properties"/><bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"><property name="user" value="${user}"></property><property name="password" value="${password}"></property><property name="driverClass" value="${driver}"></property><property name="jdbcUrl" value="${url}"></property><property name="initialPoolSize" value="${initialPoolSize}"></property><property name="maxPoolSize" value="${maxPoolSize}"></property></bean><bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"><property name="dataSource" ref="dataSource"></property><property name="configLocation" value="classpath:hibernate.cfg.xml"></property><property name="mappingLocations" value="classpath:com/ssh/entity/*.hbm.xml"></property></bean>       <bean id="employeeAction" class="com.ssh.action.EmployeeAction" scope="prototype">     <property name="employeeService" ref="employeeService"></property>     <property name="departmentService" ref="departmentService"></property>    </bean></beans>

db.properties 数据库连接的信息

user=root
password=123
driver=com.mysql.jdbc.Driver
url=jdbc:mysql:///ssh
initialPoolSize=5
maxPoolSize=10

hibernate.cfg.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC"-//Hibernate/Hibernate Configuration DTD 3.0//EN""http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration><session-factory><property name="dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property><property name="show_sql">true</property><property name="hibernate.format_sql">true</property><property name="hibernate.hbm2ddl.auto">update</property></session-factory>
</hibernate-configuration>

struts.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN""http://struts.apache.org/dtds/struts-2.3.dtd"><struts><constant name="struts.action.extension" value="action,do,"/><package name="hello" namespace="/" extends="struts-default">        <action name="emp-*" class="employeeAction" method="{1}"> <!-- class中用的并不是全类名,是在spring中管理该类的id --><result name="save" type="redirectAction">/emp-list</result></action></package>
</struts>

这样基本的开发环境就搭建好了

转载于:https://www.cnblogs.com/hfblogs/p/5253818.html

SSH开发环境整合搭建相关推荐

  1. SpringBoot-从入门到放弃(二) 开发环境的搭建

    SpringBoot-从入门到放弃(二) 开发环境的搭建 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/z23546498/article/deta ...

  2. 编写php用什么开发环境,php开发环境的搭建和使用

    php开发环境的搭建和使用 apache在默认情况下不会处理php页面,Apache处理php页面的步骤: 即:php开发环境的搭建. 1.在windows系统下搭建:apache(iis)+php+ ...

  3. android笔记1——开发环境的搭建

    Long Long ago...已经成为了历史,我还是要说出一个真相:早年前,那时候,android还不被大众所认知的时候,当然开发人员也没不像如今那样趋于饱和状态.一位大牛前辈,也是我的学长,那时候 ...

  4. Java开发环境的搭建以及使用eclipse从头一步步创建java项目

    原文:出自本人的Linux博客http://blog.csdn.net/unix21/article/details/18813173 一.Java 开发环境的搭建 这里主要说windows环境下怎么 ...

  5. Java开发环境的搭建以及使用eclipse创建项目

    一.Java 开发环境的搭建 这里主要说windows环境下怎么配置Java环境.如果是Linux环境参考本博客另一篇文章即可: Linux环境安装卸载JDK 1.首先安装JDK java的SDK简称 ...

  6. 《python 与数据挖掘 》一1.3 Python开发环境的搭建

    本节书摘来自华章出版社<python 与数据挖掘 >一书中的第1章,第1.3节,作者张良均 杨海宏 何子健 杨 征,更多章节内容可以访问云栖社区"华章计算机"公众号查看 ...

  7. 微信小程序开发系列一:微信小程序的申请和开发环境的搭建

    我最近也刚刚开始微信小程序的开发,想把我自学的一些心得写出来分享给大家. 这是第一篇,从零开始学习微信小程序开发.主要是小程序的注册和开发环境的搭建. 首先我们要在下列网址申请一个属于自己的微信小程序 ...

  8. java刚工作搭建环境_Java开发环境的搭建

    一.java 开发环境的搭建 这里主要说的是在windows 环境下怎么配置环境. 1.首先安装JDK 点击下载好的exe文件安装即可. 2.接下来我们需要配置环境变量 xp系统下  右键'我的电脑' ...

  9. python语言编程环境-day02--编程语言的分类与Python开发环境的搭建

    一.编程语言的分类 机器语言:机器语言是二进制代码表示的计算机能够直接识别和执行的一种机器指令的集合. 汇编语言:汇编语言是一种比机器语言稍微高级的编程语言,它使用助记符代表机器指令的操作码,用地址符 ...

最新文章

  1. Effective java 43返回零长度的数组或者集合而不是null
  2. 《MapReduce 2.0源码分析与编程实战》一第1章 HBase介绍
  3. 刷leetcode第705题- 设计哈希集合
  4. java http2_java的okhttp3库中,客户端如何开启http2协议支持
  5. mysql表空间段区块如何理解_Oracle表空间、段、区和块简述
  6. SQLite.NET.0.17 的离奇之处, BUG??? BY DESIGN??
  7. 高级软件工程第九次作业:东理三剑客团队作业-随笔4
  8. iOS Universal Links 配置教程
  9. 2018.11.04 洛谷P1081 开车旅行(倍增)
  10. 基于RabbitMQ RPC实现的主机异步管理
  11. 设置 jetbrains 的背景颜色和字体。
  12. [原创]恩智浦智能车电机驱动板之BTN系列驱动设计详细讲解(新手帖、附原理图和PCB)
  13. 各类软硬件简易资料830个共2.1G,感兴趣的小伙伴自行下载
  14. java 获取农历日期
  15. 计算机表格出现value,excel表格出现#value解决方法
  16. 梯度下降优化算法Momentum
  17. matlab绘制三维隐函数图像
  18. 数据结构-----------------------哈希表(最通俗易懂的文章)
  19. GNS3 思科(Cisco)PIX虚拟防火墙简单配置
  20. Android开发 assets目录

热门文章

  1. 省钱方便网上手机充话费
  2. 中国平安“豪赌”科技?从产险业务IT变形计聊起
  3. redis系列:基于redis的分布式锁
  4. 【干货】裸金属服务Ironic项目介绍
  5. 2016极客大奖颁奖盛典落幕 50个大奖勾勒中国创新图谱
  6. systemd 对你的进程数限制横插一脚啦
  7. JEECMS V3.0 常用标签使用说明
  8. 编译一个内核及分区格式化
  9. 越阳刚的男人越容易生女孩
  10. 开源项目越来越商业友好,谁来负责开发者友好呢?