applicationContext.xml中要配置

<!-- MyBatis 的 sqlSessionFactory -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="configLocation">
<value>classpath:sqlMapConfig.xml</value>
</property>
</bean>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="cn.baseapp.dao"/>
<!--
<property name="sqlSessionTemplateBeanName" value="sqlSessionTemplate" />
<property name="annotationClass" value="org.springframework.stereotype.Repository" />
-->
</bean>

MapperScannerConfigurer 支 持 过 滤 由 指 定 的 创 建 接 口 或 注 解 创 建 映 射 器 。 annotationClass 属性指定了要寻找的注解名称。 markerInterface 属性指定了要寻找的父 接口。如果两者都被指定了,加入到接口中的映射器会匹配两种标准。 默认情况下,这两个 属性都是 null,所以在基包中给定的所有接口可以作为映射器加载。因此 annotationClass 写不写都行,只要包指定到dao上就行了

参考 https://my.oschina.net/psuyun/blog/464851

用通配符配置 mapper

<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
  <property name="dataSource" ref="dataSource" />
  <property name="configLocation" value="classpath:sqlMapConfig.xml"/>
  <property name="mapperLocations" value="classpath*:sample/config/mappers/**/*.xml" />
</bean>

MyBatis SpringMVC映射配置注意的更多相关文章

  1. spring+mybatis+springmvc的配置

    1.web.xml的配置 <?xml version="1.0" encoding="UTF-8"?><web-app version=&qu ...

  2. mybatis一对一映射配置详解

    听说mybatis一对一有三种写法,今天我试了一下. 数据库表准备 为了偷懒,我直接就拿用户权限菜单里的菜单表和菜单与权限的中间表做实现,他们原来是多对多的关系,这边我假设这两张表是一对一. 表  g ...

  3. mybatis resultMap 映射配置

    现有数据库表: CREATE TABLE `dept_p` ( `DEPT_ID` ) NOT NULL, `DEPT_NAME` ) DEFAULT NULL, `PARENT_ID` ) DEFA ...

  4. 学习笔记_J2EE_SSM_01_spring+springMVC+Mybatis整合_XML配置示例

    spring+springMVC+Mybatis整合_XML配置示例 1.概述 spring+springMVC+Mybatis整合  XML配置方式 1.1 测试环境说明 名称 版本 备注 操作系统 ...

  5. springmvc+mybatis多数据源配置,AOP注解动态切换数据源

    springmvc与springboot没多大区别,springboot一个jar包配置几乎包含了所有springmvc,也不需要繁琐的xml配置,springmvc需要配置多种jar包,需要繁琐的x ...

  6. (转)springMVC+mybatis+ehcache详细配置

    一. Mybatis+Ehcache配置 为了提高MyBatis的性能,有时候我们需要加入缓存支持,目前用的比较多的缓存莫过于ehcache缓存了,ehcache性能强大,而且位各种应用都提供了解决方 ...

  7. MyBatis 关系映射XML配置

    关系映射 在我看来这些实体类就没啥太大关联关系,不就是一个sql语句解决的问题,直接多表查询就完事,程序将它设置关联就好 xml里面配置也是配置了sql语句,下面给出几个关系的小毛驴(xml) 一对多 ...

  8. mybatis由浅入深day01_6SqlMapConfig.xml(6.2settings全局参数配置_6.3typeAliases(类型别名)_6.4typeHandlers(类型处理器)_6.5mappers(映射配置))

    6 SqlMapConfig.xml mybatis的全局配置文件SqlMapConfig.xml,配置内容和顺序如下: properties(属性) settings(全局配置参数) typeAli ...

  9. Mybatis基于XML配置SQL映射器(一)

    Durid和Mybatis开发环境搭建 SpringBoot搭建基于Spring+SpringMvc+Mybatis的REST服务(http://www.cnblogs.com/nbfujx/p/76 ...

随机推荐

  1. web前端之jQuery

    前端的核心编程语言是javaScript,jQuery的出现简化了前端编程,以前看过一些,现在不用大都忘记了,以下总结几个前端技巧. 作为面向对象的脚本语言,注意区别jQuery和DOM对象,及其方法 ...

  2. J - Romantic

    The Sky is Sprite. The Birds is Fly in the Sky. The Wind is Wonderful. Blew Throw the Trees Trees ar ...

  3. 堆的C语言实现

    在C++中,可以通过std::priority_queue来使用堆. 堆的C语言实现: heap.c /** @file heap.c * @brief 堆,默认为小根堆,即堆顶为最小. */ #in ...

  4. Vue----目录结构

    目录结构: (1):build:---------------------------------------------------------------------------------:保存 ...

  5. DB2 Version 10.5 补丁下载

    DB2 Version 10.5 for Linux, UNIX, and Windows fix pack summary https://www.ibm.com/support/knowledge ...

  6. CCPC-Wannafly Winter Camp Day4 Div1 - 夺宝奇兵 - [简单思维题]

    题目链接:https://zhixincode.com/contest/18/problem/A?problem_id=259 题目描述 wls正在玩一个寻宝游戏. 宝藏一共有 $n$ 种,都藏在一个 ...

  7. [No0000EA]C# 可空类型(Nullable)

    C# 可空类型(Nullable) C# 提供了一个特殊的数据类型,nullable 类型(可空类型),可空类型可以表示其基础值类型正常范围内的值,再加上一个 null 值. 例如,Nullable& ...

  8. Sticks POJ - 1011 少林神棍 dfs四次剪枝

    http://poj.org/problem?id=1011 题意:若干根棍子被截成小段的木棒,现在给你这些木棒,问最短可以拼出的棍子长度. 题解:搜索,dfs(r,m) 二个参数分别代表还剩r个木棒 ...

  9. Eclipse各个版本区别

    1.eclipse下载地址: 最新版:http://www.eclipse.org/downloads/ 历史版:http://archive.eclipse.org/eclipse/download ...

  10. JNI 入门

    1.http://cherishlc.iteye.com/blog/1756762 Android 学习笔记--利用JNI技术在Android中调用.调试C++代码 2.http://my.eoe.c ...