所需要的jar包及其版本

  Spring 版本:4.3.18   tx、aop、beans、core、web、web-mvc、context、expression、jdbc

  MyBatis:3.4.6

  mybatis-spring:1.3.2

  mysql-connector 连接数据库:5.1.44

  fastjson 生成json:1.2.13

  druid 数据源:1.1.9

  jsr 303 数据校验:hibernate-validate4.3.2、jboss-loggin3.1.0CR2、validation-api1.0GA

  面向切面:aopaliance、aspectjweaver1.8.13

  文件上传:commons-io、commons-fileupload、commons-loggin1.2

  jsp、jstl:jstl.jar、standart.jar

  log4j:1.2.17

准备配置文件:

  database.properties  连接数据库

  log4j.properties     输出日志

  mybatis-config.xml   mybatis配置文件

  applicationContext-mybatis.xml   spring配置数据操作的配置文件

  springmvc-servlet.xml  springmvc的配置文件

  web.xml  项目配置文件

mybatis-config.xml

  

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE configuration
        PUBLIC "-//mybatis.org//DTD Config 3.0//EN"         "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
      <settings>
        <!--日志实现-->
        <setting name="logImpl" value="log4j"/>
        <!--非懒加载-->
        <setting name="lazyLoadingEnabled" value="false"/>
    </settings>
    <!--实体类别名-->
    <typeAliases>
        <package name="cn.smbms.pojo"/>
    </typeAliases>
</configuration>

applicationContext-mybatis.xml

<!--引入database.properties-->
<bean  class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">     <property name="location">         <value>classpath:database.properties</value>
    </property>
</bean>
<!--数据源-->
<bean class="com.alibaba.druid.pool.DruidDataSource" id="dataSource">     <property name="driver" value="${jdbc.driver}"/>     <property name="url" value="${jdbc.url}"/>     <property name="username" value="${jdbc.user}"/>     <property name="password" value="${jdbc.pwd}"/>
</bean>
<!--sqlSessionFactoryBean-->
<bean class="org.mybatis.spring.SqlSessionFactoryBean"  id="sqlSessionFactoryBean">     <property name="dataSource" ref="dataSource"/>
    <!--mybatis-config.xml文件-->     <property name="configLocation" value="classpath:mybatisconfig.xml"/>     <!--mapper文件路径-->
   <property name="mapperLocations">
        <list>
            <!--模糊匹配-->             <value>classpath:cn/smbms/dao/**/*.xml</value>
        </list>
    </property>
</bean> <!--批量注入映射器实现 MapperScannerConfigurer--> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">     <property name="basePackage" value="cn.smbms.dao"/>
</bean> <!--事务管理器-->
<bean  class="org.springframework.jdbc.datasource.DataSourceTransactionManager"       id="txManager">
<property name="dataSource" ref="dataSource"/>
</bean> <!--启用声明式事务注解-->
<tx:annotation-driven transaction-manager="txManager"/> <!--启用aop的增强注解-->
<aop:aspectj-autoproxy/>

springmvc-servlet.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"        xmlns:p="http://www.springframework.org/schema/p"        xsi:schemaLocation="http://www.springframework.org/schema/beans        http://www.springframework.org/schema/beans/spring-beans.xsd        http://www.springframework.org/schema/aop        http://www.springframework.org/schema/aop/spring-aop.xsd        http://www.springframework.org/schema/context        http://www.springframework.org/schema/context/spring-context.xsd        http://www.springframework.org/schema/tx        http://www.springframework.org/schema/tx/spring-tx.xsd        http://www.springframework.org/schema/mvc        http://www.springframework.org/schema/mvc/spring-mvc.xsd">     <!--支持注解配置Bean-->     <context:component-scan base-package="cn.smbms.controller"/>
    <!--视图对应-->     <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">         <property name="prefix" value="/WEB-INF/jsp/"/>         <property name="suffix" value=".jsp"/>     </bean>
<!--静态资源-->
<mvc:resources mapping="/statics/**" location="/statics/"/>
<!--spring mvc 注解支持 和消息转换器-->
<mvc:annotation-driven>
<mvc:message-converters>
<!--spring 消息转换器 防止中文乱码-->
<bean
class="org.springframework.http.converter.StringHttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>application/json;charset=utf-8</value>
</list>
</property>
</bean>
<!--fastJson 消息转换器 格式化日期-->
<bean
class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>application/json;charset=utf-8</value>
</list>
</property>
<property name="features">
<list>
<value>WriteDateUseDateFormat</value>
</list>
</property>
</bean>
</mvc:message-converters>
</mvc:annotation-driven>
<!--文件上传-->
<bean
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="defaultEncoding" value="utf-8"/>
<property name="maxUploadSize" value="2000000"/>
</bean>
<!--拦截器-->
<mvc:interceptors>
<mvc:interceptor>
<!--拦截的路径-->
<mvc:mapping path="/sys/**"/>
<bean class="cn.smbms.interceptor.SysInterceptor"/>
</mvc:interceptor>
</mvc:interceptors>
</beans>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<!--springmvc过滤器-->
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!--加载springmvc配置文件-->
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:springmvc-servlet.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>
<!--springmvc 请求编码过滤器-->
<filter>
<filter-name>encodingFilter</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>
<!--请求和响应都设置-->
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!--spring监听器-->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listenerclass>
</listener>
<!--上下文参数,指定spring配置文件所在目录-->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext-*.xml</param-value>
</context-param>
</web-app>

SSM框架整合核心内容的更多相关文章

  1. SpringMVC札集(10)——SSM框架整合

    自定义View系列教程00–推翻自己和过往,重学自定义View 自定义View系列教程01–常用工具介绍 自定义View系列教程02–onMeasure源码详尽分析 自定义View系列教程03–onL ...

  2. (转)淘淘商城系列——SSM框架整合之Dao层整合

    http://blog.csdn.net/yerenyuan_pku/article/details/72721093 一个项目中往往有三层即Dao层.Service层和Web层,看标题就知道了,本文 ...

  3. SSM框架整合模板

    SSM框架整合--MAVEN依赖 spring方面(包含了springmvc): spring-webmvc:spring与mvc的整合依赖,主要包括spring的核心包和springmvc需要的包 ...

  4. 【计理01组08号】SSM框架整合

    [计理01组08号]SSM框架整合 数据库准备 本次课程使用 MySQL 数据库.首先启动 mysql : sudo service mysql start 然后在终端下输入以下命令,进入到 MySQ ...

  5. SpringMVC详解及SSM框架整合项目

    SpringMVC ssm : mybatis + Spring + SpringMVC MVC三层架构 JavaSE:认真学习,老师带,入门快 JavaWeb:认真学习,老师带,入门快 SSM框架: ...

  6. SpringMVC--从理解SpringMVC执行流程到SSM框架整合

    前言 SpringMVC框架是SSM框架中继Spring另一个重要的框架,那么什么是SpringMVC,如何用SpringMVC来整合SSM框架呢?下面让我们详细的了解一下. 注:在学习SpringM ...

  7. struts2框架的核心内容

     Struts1和Struts2的区别和对比: Action 类: • Struts1要求Action类继承一个抽象基类.Struts1的一个普遍问题是使用抽象类编程而不是接口,而struts2的Ac ...

  8. SSM框架整合项目 :租房管理系统

    使用ssm框架整合,oracle数据库 框架: Spring SpringMVC MyBatis 导包: 1, spring 2, MyBatis 3, mybatis-spring 4, fastj ...

  9. springmvc(二) ssm框架整合的各种配置

    ssm:springmvc.spring.mybatis这三个框架的整合,有耐心一步步走. --WH 一.SSM框架整合 1.1.整合思路 从底层整合起,也就是先整合mybatis与spring,然后 ...

随机推荐

  1. Mybatis 和 Solon 在一起的升级版

    终于说通 Solon 作者,让他为 Solon 框架添加事务注解支持了:并且把 mybatis-solon-plugin 的 @Df 注解更名为 @Db ,接地气多了(Df是什么鬼呢?新手肯定这么想. ...

  2. adb修改手机分辨率

    一.手机分辨率对照表 宽×高(标准值) 240×320 320×480 480×800 720×1280 1080×1920 1440×2560 DPI等级 LDPI MDPI HDPI XHDPI ...

  3. Java成员变量和局部变量的区别

    定义位置不同: 成员变量:类中方法外 分为类变量(static修饰).实例变量(没有使用static修饰) 局部变量:方法内.代码块内 默认值不同: 成员变量:有默认初始化值 局部变量:没有默认初始化 ...

  4. 安国AU6989主控 + K9GBG08U0A(NAND) 制作4GB闪存驱动器

    文档标识符:AU6989_FLASH-DRIVE_D-P8 作者:DLHC 最后修改日期:2020.8.22 本文链接: https://www.cnblogs.com/DLHC-TECH/p/AU6 ...

  5. 操作系统-存储管理(5)IA-32/Linux的地址转换

    IA-32/Linux按字节编址:在保护模式下,IA-32采用段页式虚拟存储管理方式,存储地址采用逻辑地址.线性地址和物理地址来进行描述. 逻辑地址由48位组成,包含16位段选择符(高13位为段表项的 ...

  6. ZERO:新手应该如何学习SEO优化

    http://www.wocaoseo.com/thread-325-1-1.html 有一个10000小时理论,说是在各行各业,想成为大师级的人物就要付出10000小时的努力,在SEO这边也是如此. ...

  7. HttpServletRespnse 对象 相关基本应用

    HttpServletRespnse 对象相关基本应用 向浏览器输出数据 getOutputStream() @Override protected void service(HttpServletR ...

  8. 前后端API交互如何保证数据安全性?

    前言 前后端分离的开发方式,我们以接口为标准来进行推动,定义好接口,各自开发自己的功能,最后进行联调整合.无论是开发原生的APP还是webapp还是PC端的软件,只要是前后端分离的模式,就避免不了调用 ...

  9. 使用zabbix监控sql server的发布订阅

    (一)背景 个人在使用sql server时,用到了sql server的发布订阅来做主从同步,类似MySQL的异步复制.在发布订阅环境搭建完成后,最重要的就是如何监控复制的状态了,sql serve ...

  10. 转载:MYSQL数据库三表联查的SQL优化过程

    地址:https://database.51cto.com/art/202002/609803.htm 作者用了三张有设计缺陷的表做例子,使得优化效果空前,优化手段仅为拨乱反正和加索引,此行可为一哂.