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. tsm 切记

    切记不可删除节点,如果删除下面带的数据也会删除

  2. Maven、SpringBoot框架结构优化

    一.创建maven项目,名为test-parent,pom文件如下: ... <artifactId>test-parent</artifactId> <version& ...

  3. ThinkPad X1 Carbon 2018 Windows 10无法关机的问题

    最近两天在工作中很多同事都遇到了自己的X1电脑关机时自动重启的现象,这个问题让我在知乎.微软支持.国外各种科技论坛找到了很多类似的症状. 但是针对同事们遇到的问题,解决方案异常的简单:就是下载联想驱动 ...

  4. Ubuntu下eclipse中运行Hadoop时所需要的JRE与JDK的搭配

    第一组: Eclise 版本:Indigo,Service Release 1 Build id:20110916-0149 Window-->Preferences -->Compile ...

  5. [No0000177]详解/etc/profile、/etc/bash.bahsrc、~/.profile、~/.bashrc的用途

    之前安装Linux的一些软件时,总要修改Linux的配置文件.当时也是一知半解.而且,网上有些安装教程,会说,修改配置文件后要重启Linux.但事实上是不需要重启的. Linux安装时可能要修改的配置 ...

  6. Sharding-JDBC读写分离

    https://www.jianshu.com/p/8bbc8ca63037 官网文档:当当网,架构师张亮 http://shardingsphere.io/document/current/cn/m ...

  7. hdu6435 Problem J. CSGO标程讲解以及改正标程的一个错误(本来第一个样例过不了2333) 以及 poj2926 五维曼哈顿距离模板

    比赛的时候抄poj2926的模板,但改不来啊orz #include <iostream> #include <cstdio> #include <cstring> ...

  8. 用mysql-connector操作MySQL数据库

    首先是工具库的安装 pip install mysql-connector 连接数据库 #连接数据库 #常规连接方式 conn = mysql.connector.connect(user=', da ...

  9. elasticsearch ingest node and docker-cluster---quey using sql]

    es-docker-cluster https://stefanprodan.com/2016/elasticsearch-cluster-with-docker/ https://github.co ...

  10. odoo10 入门

    一:入门准备 1:--xmlrpc-port=<端口> 命令选项充许我们将服务器实例的侦听端口从默认8069改为指定端口.这样可以在同一服务器上同时运行多个实例. 2:使用db-filte ...