刚刚开始用spring boot和mybatis整合,有点粗糙。遇到这个问题记录一下。

步骤:

1.首先pom引入依赖

<!-- mybatis依赖 -->

<dependency>

<groupId>org.mybatis.spring.boot</groupId>

<artifactId>mybatis-spring-boot-starter</artifactId>
            <version>2.0.0</version>
        </dependency>

2.然后写mappper接口(这里有两种方法【1.使用注解 2.配置文件】)

2.1.注解:

@Mapper
public interface UserMapper {

@Delete("drop table user if exists")
    void dropTable();

@Insert("insert into user(name,age) values(#{name},#{age})")
    void insert(User user);

@Select("select id,name,age from user where name like #{name}")
    List<User> findByNameLike(String name);

@Delete("delete from user")
    void deleteAll();

}

2.2.配置(注意mapper.xml中namespace)

3.扫包,在spring主程序上面添加这个注解

@MapperScan(basePackages = "com.xxx.mapper")

4.读取配置文件(在application.xxx中写)

mybatis:
  config-location: classpath:config/mybatis-config.xml
  mapper-locations: classpath:mapper/*.xml

这几部做好整个mybatis就整合在spring boot里了。

No MyBatis mapper was found in '[com.briup.demo]' package. Please check your相关推荐

  1. No MyBatis mapper was found,Error creating bean with name 'xSqlSessionFactory' defined in class path

    springboot mybatis 项目,mapper目录下无内容 导致mvn clean package 编译打包时报错,如下: 2019-10-24 09:45:38.972 INFO 3872 ...

  2. mybatis mapper xml文件的导入方式和查询方式

    mybatis mapper xml文件的导入方式和查询方式 ssm框架 Mybatis  mapper与SQLSession的关系 每个基于MyBatis的应用都是以一个SqlSessionFact ...

  3. MyBatis mapper文件中使用常量

    MyBatis mapper文件中使用常量 Java 开发中会经常写一些静态常量和静态方法,但是我们在写sql语句的时候会经常用到判断是否等于 //静态类 public class CommonCod ...

  4. 解决JRebel对myBatis Mapper 失效的问题

    解决JRebel对myBatis Mapper 失效的问题 在之前的文章中介绍了JRebel这个插件的使用和优势,虽然它对配置文件的改动的热更新是生效的,但是mybatis的mapper文件的改动却无 ...

  5. No MyBatis mapper was found in ‘[xx.mapper]‘ package. Please check your configuration

    spring boot集成mybatisplus搭建项目,在只有spring boot时访问正常,集成后,启动项目控制台报错如标题:MyBatis: No MyBatis mapper was fou ...

  6. java.lang.NoSuchMethodException: tk.mybatis.mapper.provider.base.BaseSelectProvider.<init>()的问题解决

    在使用通用mapper进行crud的时候运行报java.lang.NoSuchMethodException: tk.mybatis.mapper.provider.base.BaseSelectPr ...

  7. 解决main No MyBatis mapper was found in 的警告

    在集成Spring + mybaits时出现以下警告 org.mybatis.spring.mapper.MapperScannerConfigurer$Scanner.main No MyBatis ...

  8. Spring 整合Mybatis Mapper动态代理方法

    先看项目目录结构 很清爽了 最重要的Spring的核心配置文件,看一下 <?xml version="1.0" encoding="UTF-8"?> ...

  9. There is no getter for property named ‘distinct‘ in ‘class tk.mybatis.mapper

    今天调试接口时候发现程序报错 There is no getter for property named 'distinct' in 'class tk.mybatis.mapper.entity.E ...

最新文章

  1. hdu 3416(最短路+最大流)
  2. VC++实现获取DNS服务器
  3. 【Linux】一步一步学Linux——sort命令(53)
  4. Struts 2框架创建的第一个项目
  5. Fedora Linux中配置JDK5或JDK6环境变量
  6. RocketMQ如何保证消息不丢失? 如何快速处理积压消息?
  7. android用java写文本框_Android 使用TextView实现验证码输入框
  8. RocketMQ的一些基本概念和RocketMQ特性的讲解
  9. 【Elasticsearch】 Full text queries query_string 等 字符串查询
  10. [Android实例] 有关spinner 的item问题 谁能给解答下??
  11. 【MySQL笔记】: unable to connect to remote host. catalog download has failed.
  12. Debit credit problem
  13. vue computed 传参_Vue的构造选项
  14. 磁盘转换|如何将mbr转换成gpt?
  15. Python 根据起始时间和结束时间计算时长
  16. 捷普服务器群组防护系统,捷普入侵防御系统
  17. Win10系统“此电脑”误删了,或者无缘无故消失了,怎么找回?
  18. b区计算机复试国家线,今年调剂太恐怖 B区考研分数线竟比A区高?
  19. 微信小程序的灰度发布
  20. 使用python scrapy爬取全国小区信息(包括小区价格,经纬度,面积,户数等),并保存到mysql和excel

热门文章

  1. Matlab - 产生高斯噪声
  2. bert中文情感分析二分类任务详解
  3. CASAIM和工信部第五研究所(中国赛宝实验室)合作开展三维测量技术在产品可靠性研究的精确尺寸检测应用和建模仿真试验
  4. 嵌入式 linux yum命令详解
  5. Excel破解工作表保护密码
  6. DataStage简介
  7. EasyExcel之回填下拉框
  8. java中工具插件列表
  9. 傅立叶变换的原理、意义以及如何用Matlab实现快速傅立叶变换
  10. 一、Tomcat 配置