No MyBatis mapper was found in '[com.briup.demo]' package. Please check your
刚刚开始用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相关推荐
- 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 ...
- mybatis mapper xml文件的导入方式和查询方式
mybatis mapper xml文件的导入方式和查询方式 ssm框架 Mybatis mapper与SQLSession的关系 每个基于MyBatis的应用都是以一个SqlSessionFact ...
- MyBatis mapper文件中使用常量
MyBatis mapper文件中使用常量 Java 开发中会经常写一些静态常量和静态方法,但是我们在写sql语句的时候会经常用到判断是否等于 //静态类 public class CommonCod ...
- 解决JRebel对myBatis Mapper 失效的问题
解决JRebel对myBatis Mapper 失效的问题 在之前的文章中介绍了JRebel这个插件的使用和优势,虽然它对配置文件的改动的热更新是生效的,但是mybatis的mapper文件的改动却无 ...
- No MyBatis mapper was found in ‘[xx.mapper]‘ package. Please check your configuration
spring boot集成mybatisplus搭建项目,在只有spring boot时访问正常,集成后,启动项目控制台报错如标题:MyBatis: No MyBatis mapper was fou ...
- java.lang.NoSuchMethodException: tk.mybatis.mapper.provider.base.BaseSelectProvider.<init>()的问题解决
在使用通用mapper进行crud的时候运行报java.lang.NoSuchMethodException: tk.mybatis.mapper.provider.base.BaseSelectPr ...
- 解决main No MyBatis mapper was found in 的警告
在集成Spring + mybaits时出现以下警告 org.mybatis.spring.mapper.MapperScannerConfigurer$Scanner.main No MyBatis ...
- Spring 整合Mybatis Mapper动态代理方法
先看项目目录结构 很清爽了 最重要的Spring的核心配置文件,看一下 <?xml version="1.0" encoding="UTF-8"?> ...
- 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 ...
最新文章
- hdu 3416(最短路+最大流)
- VC++实现获取DNS服务器
- 【Linux】一步一步学Linux——sort命令(53)
- Struts 2框架创建的第一个项目
- Fedora Linux中配置JDK5或JDK6环境变量
- RocketMQ如何保证消息不丢失? 如何快速处理积压消息?
- android用java写文本框_Android 使用TextView实现验证码输入框
- RocketMQ的一些基本概念和RocketMQ特性的讲解
- 【Elasticsearch】 Full text queries query_string 等 字符串查询
- [Android实例] 有关spinner 的item问题 谁能给解答下??
- 【MySQL笔记】: unable to connect to remote host. catalog download has failed.
- Debit credit problem
- vue computed 传参_Vue的构造选项
- 磁盘转换|如何将mbr转换成gpt?
- Python 根据起始时间和结束时间计算时长
- 捷普服务器群组防护系统,捷普入侵防御系统
- Win10系统“此电脑”误删了,或者无缘无故消失了,怎么找回?
- b区计算机复试国家线,今年调剂太恐怖 B区考研分数线竟比A区高?
- 微信小程序的灰度发布
- 使用python scrapy爬取全国小区信息(包括小区价格,经纬度,面积,户数等),并保存到mysql和excel