欢迎来到代码驿站!

JAVA代码

当前位置:首页 > 软件编程 > JAVA代码

Springboot mybatis常见配置问题解决

时间:2021-04-01 08:17:34|栏目:JAVA代码|点击:

这篇文章主要介绍了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注解

上一篇:学习Java多线程之线程定义、状态和属性

栏    目:JAVA代码

下一篇:BMIDE环境导入项目报编码错误解决方案

本文标题:Springboot mybatis常见配置问题解决

本文地址:http://www.codeinn.net/misctech/92183.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有