Springboot mybatis常见配置问题解决
2019-12-02 18:11
1081 查看
这篇文章主要介绍了Springboot mybatis常见配置问题解决,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
Invalid bound statement (not found): com.example.blog.dao.DemoMapper.selectByExample"
打包的时候没有打包 mapper.xml 文件
<resource> <directory>src/main/resources</directory> <includes> <include>**/*</include> </includes> </resource> <resource> <directory>src/main/java</directory> <includes> <include>**/*.xml</include> </includes> </resource>
没有扫描到 mapper.xml 文件
mybatis: # mapper.xml 文件路径 mapper-locations: classpath:com/example/blog/dao/mapper/*.xml # mybatis的xml文件中需要写类的全限定名,可以配置自动扫描包路径给类配置别名 type-aliases-package: com.example.blog.entity
Field demoMapper in com.example.demo.service.DemoServiceImpl required a bean of type 'com.example.demo.dao.DemoMapper' that could not be found.
原因:找不到dao层的mapper文件
启动类添加mapper扫描
@MapperScan("com.example.demo.dao") @SpringBootApplication public class BlogApplication { }
添加@Mapper注解
以上就是本文的全部内容,希望对大家的学习有所帮助
您可能感兴趣的文章:
相关文章推荐
- spring-boot集成mybatis问题1:IntellijIdea中j解决自动生成代码xml配置文件中出现“uri is not registered”问题
- Spring boot + shiro 跨域配置(解决jsessionid丢失问题)
- 解决springboot部署时使用外部文件配置项目参数的问题
- SpringBoot配置Cors解决跨域问题
- 关于Spring boot中读取属性配置文件出现中文乱码的问题的解决
- Springboot整合Mybatis的CallSettersOnNulls配置问题
- Springboot 之 解决IDEA读取properties配置文件的中文乱码问题
- spring-boot-plus 常见问题解决 FAQ(十二)
- 解决eclipse创建spring boot项目加载不到application.properties配置文件的问题
- @maohoo Spring boot 配置Tomcat 根目录,解决web资源目录找不到的问题
- Springboot 之 解决IDEA读取properties配置文件的中文乱码问题
- 一个由于springboot自动配置所产生的问题的解决
- SpringBoot Mybatis解决使用PageHelper一对多分页问题
- shiro+spring boot+mybatis启动循环引用问题解决思路和方案
- 在Mybatis-spring中由于默认Autowired导致不能配置多个数据源的问题分析及解决
- spring 打入jar包 xml配置路径,加载异常等常见问题解决方法
- Springboot 之 解决IDEA读取properties配置文件的中文乱码问题
- 解决Intellij Idea Spring Boot Mybatis @Autowired报错的问题
- Spring Boot基本配置和常见的运行时错误以及解决
- SpringBoot配置Cors解决跨域请求问题