一.创建数据库名字为:dungouoa

create database dungouoa default character set utf8;
mysql> show create database dungouoa;
+----------+-------------------------------------------------------------------+
| Database | Create Database |
+----------+-------------------------------------------------------------------+
| dungouoa | CREATE DATABASE `dungouoa` /*!40100 DEFAULT CHARACTER SET utf8 */ |
+----------+-------------------------------------------------------------------+

二.创建eclips的工程
@1创建web工程,编码设为utf-8

@2添加框架环境
Junit

@1Structs2

添加jar包,

修改structs.xml,

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <constant name="struts.enable.DynamicMethodInvocation" value="false" />
<!-- 配置为开发模式-->
<constant name="struts.devMode" value="true" />
<!--把扩展名配置为action -->
<constant name="struts.action.extension" value="action" />
<!--把主题配置为simple -->
<constant name="struts.ui.theme" value="simple" /> <package name="default" namespace="/" extends="struts-default"> </package> <!-- Add packages here --> </struts>

web.xml的structs2过滤器拷贝到工程的web.xml中

@2Spring

jar包

applicationContext.xml  / bean.xml

<?xml version="1.0" encoding="UTF-8"?>
<!--
- Middle tier application context definition for the image database.
-->
<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"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<!--自动扫描预装配bean --> <context:component-scan base-package="cn.hui.oa"></context:component-scan> </beans>

@3Hibernate

jar包,

主配置文件,映射文件

<?xml version='1.0' encoding='utf-8'?>
<!--
~ Hibernate, Relational Persistence for Idiomatic Java
~
~ Copyright (c) 2010, Red Hat Inc. or third-party contributors as
~ indicated by the @author tags or express copyright attribution
~ statements applied by the authors. All third-party contributions are
~ distributed under license by Red Hat Inc.
~
~ This copyrighted material is made available to anyone wishing to use, modify,
~ copy, or redistribute it subject to the terms and conditions of the GNU
~ Lesser General Public License, as published by the Free Software Foundation.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
~ for more details.
~
~ You should have received a copy of the GNU Lesser General Public License
~ along with this distribution; if not, write to:
~ Free Software Foundation, Inc.
~ 51 Franklin Street, Fifth Floor
~ Boston, MA 02110-1301 USA
-->
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <!-- 1.数据库连接信息 -->
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<!--配置数据库的url位本地的名称为 testjdbc的数据库 -->
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/dungouoa</property>
<!--配置用户名 -->
<property name="hibernate.connection.username">root</property> <!--配置密码 -->
<property name="hibernate.connection.password">241602</property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<!-- SQL dialect mysql方言-->
<property name="dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property> <!-- 其他配置 -->
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property> <property name="hbm2ddl.auto">update</property> <!-- 导入映射文件 -->
<mapping resource="org/hibernate/tutorial/hbm/Event.hbm.xml"/> </session-factory> </hibernate-configuration>

@3整合SSH
------Structs2和Spring整合

-------整合之前Structs2测试,添加action

action类

jsp页

测试的运行结果

网页显示

-------Spring整合之前测试

-------测试类

------声明bean对象,使用注解,四种方式

配置bean的作用域,多例,不写Scope为单例

不使用注解的话则在xml文件重配置声明bean

测试后报错如下:

java.lang.ExceptionInInitializerError
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [beans.xml]; nested exception is java.lang.IllegalStateException: Context namespace element 'component-scan' and its parser class [org.springframework.context.annotation.ComponentScanBeanDefinitionParser] are only available on JDK 1.5 and higher

经查阅后是Spring和JDK版本兼容问题,后来我把所有前面导入的与spring有关jar包都删除,换成下面3.2.9的jar包后成功了

单独spring测试结果

------Structs2和Spring整合测试

-------1.在web.xml中配置SPRING用于容器对象初始化的监听器

------2.添加一个插件和两个jar包

structs.xml文件

结果展示:

Hibernate和Spring整合

目的:

@1管理SessionFactory对象,一个实例

@2声明事务管理

添加jar包

applicationContext.xml中配置加入如下

    <!-- 配置SessionFactory对象 -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<!-- 指定配置文件路径 -->
<property name="configLocation" value="classpath:hibernate.cfg.xml"></property>
<!-- 配置c3p0数据库连接池 -->
<property name="dataSource">
<bean class="com.mchange.v2.c3p0.ComboPooledDataSource">
<!-- 数据连接信息 -->
<property name="driverClass" value="com.mysql.jdbc.Driver"></property>
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/dungouoa"></property>
<property name="user" value="root"></property>
<property name="password" value="241602"></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>

运行后报错:

org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [org.springframe

导入如下jar包即可

运行结果:

Spring

IOC:管理对象

AOP:事务管理

----声明事务管理

运行报错:

org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component c

编译器的JDK1.8改为1.7即可解决

JUnit测试运行结果:

@4资源分类
@5配置日志

SSH的Eclips环境搭建的更多相关文章

  1. eclipse中SSH三大框架环境搭建<三>

    相关链接: eclipse中SSH三大框架环境搭建<一> eclipse中SSH三大框架环境搭建<二> 引言:通过上两篇文章我们已经可以掌握struts2和spring的环境的 ...

  2. eclipse中SSH三大框架环境搭建<二>

    通过上一篇博客我们可以轻松搭建strtus2的环境,接下来由我来继续介绍spring的环境搭建以及spring注入的简单使用 相关链接:eclipse中SSH三大k框架环境搭建<一> ec ...

  3. eclipse中SSH三大框架环境搭建<一>

    这里先简单介绍一下我用的三大框架版本以及下载地址 相关链接:eclipse中SSH三大框架环境搭建<二> eclipse中SSH三大框架环境搭建<三> struts-2.3.3 ...

  4. SSH框架总结(环境搭建+框架分析+实例源码下载)

    一.SSH框架简介 SSH是struts+spring+hibernate集成的web应用程序开源框架. Struts:用来控制的,核心控制器是Controller. Spring:对Struts和H ...

  5. SSH实战 · SSH项目开发环境搭建

    一:SSH整合 创建一个新的WEB项目 引入struts2.3.15.3: jar包:                 struts-2.3.15.3\apps\struts2-blank.war\W ...

  6. 最新版ssh hibernate spring struts2环境搭建

    最新版ssh hibernate spring struts2环境搭建 最新版spring Framework下载地址:spring4.0.0RELEASE环境搭建 http://repo.sprin ...

  7. SSH框架总结(框架分析+环境搭建+实例源码下载) 《转》

    这篇文章比较易懂,易理解: 首先,SSH不是一个框架,而是多个框架(struts+spring+hibernate)的集成,是目前较流行的一种Web应用程序开源集成框架,用于构建灵活.易于扩展的多层W ...

  8. SSH框架总结(框架分析+环境搭建+实例源码下载)

    来源于: http://blog.csdn.net/shan9liang/article/details/8803989 首先,SSH不是一个框架,而是多个框架(struts+spring+hiber ...

  9. [Java] SSH框架笔记_框架分析+环境搭建+实例源码下载

    首先,SSH不是一个框架,而是多个框架(struts+spring+hibernate)的集成,是目前较流行的一种Web应用程序开源集成框架,用于构建灵活.易于扩展的多层Web应用程序. 集成SSH框 ...

随机推荐

  1. 蓝桥杯-李白打酒-java

    /* (程序头部注释开始) * 程序的版权和版本声明部分 * Copyright (c) 2016, 广州科技贸易职业学院信息工程系学生 * All rights reserved. * 文件名称: ...

  2. hdu1269强连通分量入门题

    https://vjudge.net/contest/156688#problem 为了训练小希的方向感,Gardon建立了一座大城堡,里面有N个房间(N<=10000)和M条通道(M<= ...

  3. Jenkins + Maven + Ansible + Tomcat 实现JAVA代码自动部署

    自动部署过程: jenkins从svn拉取代码,调用maven去打war包,用ansible去解压war包,最后重启tomcat. 前情回顾:在前面的文章我的环境已经有Jenkins+ansible ...

  4. 我的Cocos2dx开发模式

    编程环境: 1.window 7 32bit 2.cocos2dx 3.0 3.python 2.7 (注意不要使用3.0以上版本,除非cocos2dx推荐使用) 4.apache-ant-1.9.3 ...

  5. [js笔记整理]事件篇

    一.事件流1.冒泡事件:从特定的事件到不特定事件依次触发:(由DOM层次的底层依次向上冒泡)(1)示例: <html onclick="add('html<br>')&qu ...

  6. [刷题]算法竞赛入门经典(第2版) 5-13/UVa822 - Queue and A

    题意:模拟客服MM,一共有N种话题,每个客服MM支持处理其中的i个(i < N),处理的话题还有优先级.为了简化流程方便出题,设每个话题都是每隔m分钟来咨询一次.现知道每个话题前来咨询的时间.间 ...

  7. GreenDao 使用二

    1.创建一个实体类 1 Entity note = schema.addEntity("Note"); 默认表名就是类名,也可以自定义表名 1.dao.setTableName(& ...

  8. Python装饰器实现几类验证功能做法

    最近新需求来了,要给系统增加几个资源权限.尽量减少代码的改动和程序的复杂程度.所以还是使用装饰器比较科学 之前用了一些登录验证的现成装饰器模块.然后仿写一些用户管理部分的权限装饰器.比如下面这种 de ...

  9. WINFORM数据库操作,有点像安装里面的SQLITE

    程序设计要求 设计一个用户管理系统,对系统中的用户进行管理.假定,用户表中有下列字段:用户名,密码,电话和 email 等信息.要求,1)利用 SQL server 首先创建用户数据表:2)实现对用户 ...

  10. `DevOps`相关知识搜集

    本文记录的是搞清楚什么是DevOps过程中检索资料时发现的有价值的帖子. 传送门: 我眼中的DevOps 作者简介:申思维,2005年本科毕业于华南理工大学计算机学院.一直从事Web领域的开发,3年多 ...