web.xml

 <?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<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>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> <servlet>
<servlet-name>dispatcherServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>dispatcherServlet</servlet-name>
<url-pattern>*.action</url-pattern>
</servlet-mapping>
</web-app>

  

  spring.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:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.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
"> <!--扫描注解,目的就是对相关的javabean实例化-->
<context:component-scan base-package="com.iotek"/> <!--启用springmvc的注解模式-->
<mvc:annotation-driven /> <!--DataSource-->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="com.mysql.jdbc.Driver"></property>
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/newsdb"></property>
<property name="user" value="root"></property>
<property name="password" value="root"></property>
<!--连接池启动的时候默认创建的连接数量-->
<property name="initialPoolSize" value="3"></property>
<!--连接池最多可以管理的连接对象个数-->
<property name="maxPoolSize" value="100"></property>
<!--连接池中最多能够管理的statement对象-->
<property name="maxStatements" value="1000"></property>
<!--一旦连接池中现有的连接数量不够,每次增长的连接数目:5 ,但是连接池中的连接数量-->
<!--最多不可超过maxPoolSize中设置的连接数目-->
<property name="acquireIncrement" value="5"></property>
</bean> <!--Factory-->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<!--配置mapper中使用的实体类别名-->
<property name="typeAliasesPackage" value="com.iotek.entity"/>
<!--mapper文件的路径
classpath*:com/iotek/mapper/**/*.xml : classpath,从源文件角度就是src,实际上是运行时候的classes目录
com.iotek.mapper包,以及它所有的子包里面的xml文件,都会认为是mapper文件
-->
<property name="mapperLocations" value="classpath*:com/iotek/mapper/**/*.xml"/>
</bean> <!--
DAO层位置的确定
-->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
<!--指定dao接口的位置-->
<property name="basePackage" value="com.iotek.dao"/>
</bean> <!--TransactionManager-->
<bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"></property>
</bean> <!--注解或AOP的方式使用声明式事务-->
<tx:annotation-driven transaction-manager="txManager"></tx:annotation-driven> </beans>
     <tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="create*"/>
<tx:method name="query*"/>
<tx:method name="update*"/>
<tx:method name="delete*"/>
</tx:attributes>
</tx:advice> <aop:config>
<!--切面的配置 id表示切面的唯一id,ref表示切面的支持类-->
<aop:pointcut id="operate" expression="execution(* com.iotek.service.*.*(..))"/><!--切点( 切入点)-->
<aop:advisor advice-ref="txAdvice" pointcut-ref="operate"/>
</aop:config>

SpringMVC + MyBatis 配置文件的更多相关文章

  1. Spring+SpringMVC+MyBatis深入学习及搭建(三)——MyBatis全局配置文件解析

    转载请注明出处:http://www.cnblogs.com/Joanna-Yan/p/6874672.html 前面有写到Spring+SpringMVC+MyBatis深入学习及搭建(二)——My ...

  2. spring(一)--spring/springmvc/spring+hibernate(mybatis)配置文件

    这篇文章用来总结一下spring,springmvc,spring+mybatis,spring+hibernate的配置文件 1.web.xml 要使用spring,必须在web.xml中定义分发器 ...

  3. springmvc 项目完整示例04 整合mybatis mybatis所需要的jar包 mybatis配置文件 sql语句 mybatis应用

    百度百科: MyBatis 本是apache的一个开源项目iBatis, 2010年这个项目由apache software foundation 迁移到了google code,并且改名为MyBat ...

  4. springmvc整合mybatis 配置文件

    使用SSM(Spring.SpringMVC和Mybatis)已经有三个多月了,项目在技术上已经没有什么难点了,基于现有的技术就可以实现想要的功能,当然肯定有很多可以改进的地方.之前没有记录SSM整合 ...

  5. SSM:spring+springmvc+mybatis框架中的XML配置文件功能详细解释(转)

    原文:https://blog.csdn.net/yijiemamin/article/details/51156189# 这几天一直在整合SSM框架,虽然网上有很多已经整合好的,但是对于里面的配置文 ...

  6. 【springmvc+mybatis项目实战】杰信商贸-5.生产厂家DAO+SERVICE+CONTROLLER+JSP+配置文件

    上一篇我们创建了工程和一个Factory的po对象(javaBean),我们也写好了Mapper的映射文件,接下来我们来完成生产厂家的DAO与SERVICE,以及CONTROLLER,还有做显示的JS ...

  7. 0927-转载:SSM:spring+springmvc+mybatis框架中的XML配置文件功能详细解释

    这篇文章暂时只对框架中所要用到的配置文件进行解释说明,而且是针对注解形式的,框架运转的具体流程过两天再进行总结. spring+springmvc+mybatis框架中用到了三个XML配置文件:web ...

  8. SSM:spring+springmvc+mybatis框架中的XML配置文件功能详细解释

    这几天一直在整合SSM框架,虽然网上有很多已经整合好的,但是对于里面的配置文件并没有进行过多的说明,很多人知其然不知其所以然,经过几天的搜索和整理,今天总算对其中的XML配置文件有了一定的了解,所以拿 ...

  9. Spring整合SpringMVC + Mybatis基础框架的配置文件

    目录 前言 1. Mybatis层编写 2. Spring层编写 1. Spring整合Mybatis 2. Spring整合service 3. SpringMVC层编写 1. 编写web.xml ...

随机推荐

  1. canves图形变换

    canves用得好可以有好多效果: html:<canvas id="myCanvas" width="700" height="300&quo ...

  2. jQuery——jQuery选择器

    基本选择器 # Id选择器 $(“#btnShow”)选择id为btnShow的一个元素 . 类选择器 $(“.liItem”)选择含有类liItem的所有元素 ele 标签选择器 $(“li”)选择 ...

  3. JS——模拟百度搜索

    注意事项: 1.for循环移除子节点时,其长度是变化的 2.在文档流中,input.img.p等标签与其他标签有3px的距离,利用左浮动,可以消除3px距离 3.背景图片定位时,第一个值是x轴方向的值 ...

  4. html——meta标签、link标签

    <meta> 元素可提供有关页面的元信息(meta-information),比如针对搜索引擎和更新频度的描述和关键词. <meta> 标签位于文档的头部,不包含任何内容.&l ...

  5. (转)Struts2快速入门

    http://blog.csdn.net/yerenyuan_pku/article/details/66187307 Struts2框架的概述 Struts2是一种基于MVC模式的轻量级Web框架, ...

  6. 27.8 执行定时计算限制操作(Timer)

    private static System.Threading.Timer s_Timer; static void Main() { Console.WriteLine("checking ...

  7. Python ---- KMP(博文推荐+代码)

    既解决完后宫问题(八皇后问题)后,又利用半天的时间完成了著名的“看毛片”算法——KMP.对于初学者来说这绝对是个大坑,非常难以理解. 在此,向提出KMP算法的三位大佬表示诚挚的敬意.!!!牛X!!! ...

  8. HDU 1465(错排公式)

    不容易系列之一 题意: 一个人要寄n个信封,结果装错了.信纸的编号为1到n,信封的编号为1到n,信纸的编号不能和信封的编号一样,全都不能一样. 思路:错排公式. D(n)表示n件信封装错的所有的情况. ...

  9. Linux - docker基础

    目录 Linux - docker基础 docker的概念 docker安装流程 docker基本命令学习 docker 的 hello docker 运行一个ubuntu容器 Docker与Cent ...

  10. sql server的 between and 日期问题