1、新建web项目,将所需jar包放到 lib 目录下

2、配置web.xml 配置文件

 <?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
<display-name>SchoolResourceRepository</display-name>
<filter>
<filter-name>Set Character Encoding</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>utf-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>Set Character Encoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<context-param>
<param-name>CharEncode</param-name>
<param-value>utf-8</param-value>
</context-param>
<!-- <filter>
<filter-name>charEncode</filter-name>
<filter-class>net.wwwyibu.filter.CharEncodeFilter</filter-class>
<async-supported>true</async-supported>
</filter>
<filter-mapping>
<filter-name>charEncode</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>charEncode</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>charEncode</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>charEncode</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>--> <!-- <filter>
<filter-name>loginFilter</filter-name>
<filter-class>net.wwwyibu.filter.StuZHMassgeLoginFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>loginFilter</filter-name>
<url-pattern>/stuZHMessage/*</url-pattern>
</filter-mapping> --> <!-- <filter>
<filter-name>loginFilter</filter-name>
<filter-class>net.wwwyibu.filter.LoginOutFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>loginFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> --> <context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
WEB-INF\classes\applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<!-- 监听初始化学校代码 -->
<!-- <listener>
<listener-class>net.wwwyibu.filter.ServletListener</listener-class>
</listener> --> <servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>/static/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<description>加载/WEB-INF/spring-mvc/目录下的所有XML作为Spring MVC的配置文件</description>
<param-name>contextConfigLocation</param-name>
<param-value>WEB-INF\classes\applicationContext.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<filter>
<filter-name>HiddenHttpMethodFilter</filter-name>
<filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>HiddenHttpMethodFilter</filter-name>
<servlet-name>springmvc</servlet-name>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>

3、SpringContext.xml配置文件 和 Spring-mvc.xml配置文件,这两个可以写到一个xml文件中,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:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/util spring-util-3.2.xsd
http://www.springframework.org/schema/tx spring-tx-3.2.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
http://www.springframework.org/schema/aop spring-aop-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd">
<!-- 让Spring通过自动扫描来查询和管理Bean -->
<context:component-scan base-package="net.wwwjpz" /> <context:annotation-config /> <mvc:annotation-driven />
<!-- 加載 properties 配置文件 -->
<bean id="propertyConfig"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>classpath:jdbc.properties</value>
<!-- <value>file:D:/YiBuProperties/SchoolResourceRepository/jdbc.properties</value> -->
</property>
<property name="ignoreUnresolvablePlaceholders" value="true" />
</bean> <!-- <bean id="ExcelDatabase" class="net.wwwyibu.service.ExcelDatabase"></bean>
<bean id="MedicalService" class="net.wwwyibu.service.MedicalService"></bean>
<bean id="StudentService" class="net.wwwyibu.service.StudentService"></bean>
<bean id="UploadService" class="net.wwwyibu.service.UploadService"></bean>
<bean id="SaveHealthService" class="net.wwwyibu.service.SaveHealthService"></bean>
<bean id="EvaluationService" class="net.wwwyibu.service.EvaluationService"></bean>
<bean id="ZhsjService" class="net.wwwyibu.service.ZhsjService"></bean>
<bean id="ExamService" class="net.wwwyibu.service.ExamService"></bean> -->
<!-- <bean id="ExcelCheckService" class="net.wwwyibu.service.ExcelCheckService"></bean> --> <!--
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="defaultEncoding" value="UTF-8"/>
<property name="maxUploadSize" value="20971520"/>
<property name="resolveLazily" value="true"/>
</bean> --> <bean id="dateSource" class="org.logicalcobwebs.proxool.ProxoolDataSource">
<property name="driver">
<value>${jdbc.driver}</value>
</property>
<property name="driverUrl">
<value>${jdbc.url}</value>
</property>
<property name="user">
<value>${jdbc.username}</value>
</property>
<property name="alias">
<value>${jdbc.username}</value>
</property>
<property name="password">
<value>${jdbc.password}</value>
</property> <property name="maximumActiveTime">
<value>1200000</value>
</property>
<property name="prototypeCount">
<value>100</value>
</property>
<property name="maximumConnectionCount">
<value>100</value>
</property>
<property name="minimumConnectionCount">
<value>10</value>
</property>
<property name="simultaneousBuildThrottle">
<value>500</value>
</property>
<property name="trace">
<value>true</value>
</property>
<property name="verbose">
<value>true</value>
</property>
<property name="testBeforeUse">
<value>true</value>
</property>
<property name="houseKeepingTestSql">
<value>select 1 from dual</value>
</property> </bean> <bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource">
<ref bean="dateSource" />
</property>
</bean> <bean id="transactionManagerHib"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean> <bean id="transactionInterceptor"
class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionManager" ref="transactionManagerHib" /> <property name="transactionAttributes">
<props>
<prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="is*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="load*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="query*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="check*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="insert*">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
<prop key="save*">PROPAGATION_REQUIRED</prop>
<prop key="delete*">PROPAGATION_REQUIRED,-BussException</prop>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean> <bean id="autoProxyCreator"
class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
<property name="interceptorNames">
<list>
<idref bean="transactionInterceptor" />
</list>
</property>
<property name="beanNames">
<list>
<value>/yeepayCallBack,Add_Re,*DAO</value>
</list>
</property>
</bean> <bean id="hibernateDaoTemplate" abstract="true">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean> <bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dateSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<!-- <prop key="hibernate.dialect">net.wwwyibu.util.MySQL5DialectRegexp</prop> -->
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">none</prop> <!--<prop key="hibernate.current_session_context_class">thread</prop> -->
<prop key="hibernate.jdbc.batch_size">50</prop>
<prop key="hibernate.jdbc.fetch_size">50</prop>
<!--代表使用Hibernate的二级缓存 -->
<prop key="hibernate.cache.use_second_level_cache">true</prop>
<!--代表是否使用查询缓存,这里不使用,因为一般而言查询缓存的命中率并不是很高,所以我们没有 必要为每一个用户的查询缓存它的数据,所以这里设为false -->
<prop key="hibernate.cache.use_query_cache">false</prop>
<!--用于指定使用缓存产品的驱动类 -->
<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
</props>
</property>
<property name="mappingResources">
<list>
<!-- <value>net/wwwyibu/orm/Student.hbm.xml</value>
<value>net/wwwyibu/orm/Studentclass.hbm.xml</value> -->
</list>
</property>
</bean>
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<!-- 上传文件大小上限,单位为字节(10MB) -->
<property name="maxUploadSize">
<value>10485760</value>
</property>
<!-- 请求的编码格式,必须和jSP的pageEncoding属性一致,以便正确读取表单的内容,默认为ISO-8859-1 -->
<property name="defaultEncoding">
<value>UTF-8</value>
</property>
</bean> <!-- mvc --> <bean
class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />
<bean
class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" /> <!-- Default ViewResolver -->
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/" />
<property name="suffix" value=".jsp"></property>
</bean>
<mvc:default-servlet-handler />
<!-- mvc --> </beans>

spring+springmvc+hibernate 框架搭建的更多相关文章

  1. SSH(Spring SpringMVC Hibernate)框架整合

    项目说明: 使用SSH(Spring SpringMVC Hibernate)框架整合添加部门功能 项目结构   1.导入依赖jar包 <!--单测--> <dependency&g ...

  2. Maven搭建简单的SPring+SpringMVC+Hibernate框架

    公司的项目用到的框架是Spring+SpringMVC+Hibernate 以前没有用过,所以要系统的学习一下,首先要学会怎么搭建 第一步  创建一个Maven的web项目  创建方法以前的博客中有提 ...

  3. SSM(Spring +SpringMVC + Mybatis)框架搭建

    SSM(Spring +SpringMVC + Mybatis)框架的搭建 最近通过学习别人博客发表的SSM搭建Demo,尝试去搭建一个简单的SSMDemo---实现的功能是对用户增删改查的操作 参考 ...

  4. Spring+Spring MVC+Hibernate框架搭建实例

    前言:这里只是说明整个搭建流程,并不进行原理性的讲解 一 下面所需要用到的数据库配置: 数据库方面,使用mysql创建一个users表,具体代码如下: 1 2 3 4 5 6 7 8 9 10 11 ...

  5. 【SSM 6】Spring+SpringMVC+Mybatis框架搭建步骤

    一.整体概览 首先看maven工程的创建 二.各层的文件配置 2.1,SSM父工程 <span style="font-family:KaiTi_GB2312;font-size:18 ...

  6. 简单Spring+Struts2+Hibernate框架搭建

    使用Maven+Spring+Struts2+Hibernate整合 pom文件 <project xmlns="http://maven.apache.org/POM/4.0.0&q ...

  7. spring+springmvc+mybatis框架搭建

    一.开发前准备 1)ecplise4.11.0 百度网盘:https://pan.baidu.com/s/1wO9_I52lp0mYNeNTdnj80w 提取码:booa 2)jdk1.6.0_45  ...

  8. 基于Maven的ssm(spring+springMvc+Mybatis)框架搭建

    前言 本demo是在idea下搭建的maven项目,数据库使用Mysql,jdk版本是1.8.0_171,ideal:2017.3.5 一.新建项目 1.file->new->porjec ...

  9. spring+struts2+hibernate框架搭建(Maven工程)

    搭建Spring 1.porm.xml中添加jar包 <!-- spring3 --> <dependency> <groupId>org.springframew ...

随机推荐

  1. vue使用动态渲染v-model输入框无法输入内容

    最近使用ElementUI框架,在动态渲染表单的时候,表单框无法输入内容,但是绑定model的数据是会发生变化 解决方法: 将动态生成的表单对象,深拷贝到 data 对象中 <el-date-p ...

  2. jqgrid自定义列表开发=》实现高级查询

    标题已指出本文要说的三件事,首先是主角jqgrid,将应用在自定义列表中,重点介绍如何实现高级查询. 使用jqgrid实现自定义列表分为两大步骤,首先是要根据业务完成jqgrid的对象定义,即列表的描 ...

  3. c# 类的历遍和历遍操作

    string id = Request.Form["id"]; string type = Request.Form["type"]; string info ...

  4. Tensorflow实战系列之四:

    这个是第四篇,打算写一些语义分割的内容实战.

  5. C#获取常用的路径

    常用的这两个足够了,其他需要的自行百度 //获取新的 Process 组件并将其与当前活动的进程关联的主模块的完整路径,包含文件名(进程名). string str = System.Diagnost ...

  6. 2017年5月11日17:43:06 rabbitmq 消费者队列

    从昨天开始发现个问题,一个接口在本地调用时大部分正常,一旦在生成者打一个断点调试,并且在promotion也打断点的时候会出现没有返回channel的异常,然后消费者就再也消费不了了 16:57:45 ...

  7. Python成长之路【第二篇】Python基础之数据类型

    阅读目录 简介 1 什么是数据? x=10,10是我们要存储的数据 2 为何数据要分不同的类型 数据是用来表示状态的,不同的状态就应该用不同的类型的数据去表示 3 数据类型 数字(整形,长整形,浮点型 ...

  8. 第四次Scrum编码冲刺

    第四次Scrum编码冲刺!!!! 一.总体任务: 本次冲刺是完成对图书馆管理系统的最后三个功能的实现------管理员对用户授权.用户注销和用户查询 二.个人任务及完成情况:    本人本次的任务是实 ...

  9. 注意&&前后两个表达式有顺序的差别

    //插入排序 public static void insertSort(int[] arr) { // 遍历所有数字 for (int i = 1; i < arr.length; i++) ...

  10. Python_文件处理

    1.Python  文件处理 打开文件---->读取内容---->获得内容 读取文件方式:  r  只读文件  w 只写模式 a 追加模式 r+b 读写模式   w+b 写读模式  a+b ...