新网创想网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

Springbootmybatis常见配置问题解决

这篇文章主要介绍了Springboot mybatis常见配置问题解决,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下

创新互联专注于大连网站建设服务及定制,我们拥有丰富的企业做网站经验。 热诚为您提供大连营销型网站建设,大连网站制作、大连网页设计、大连网站官网定制、小程序制作服务,打造大连网络公司原创品牌,更为您提供大连网站排名全网营销落地服务。

Invalid bound statement (not found): com.example.blog.dao.DemoMapper.selectByExample"

打包的时候没有打包 mapper.xml 文件


        src/main/resources
        
          **/*
        
      
      
        src/main/java
        
          **/*.xml
        
      

没有扫描到 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注解

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持创新互联。


当前名称:Springbootmybatis常见配置问题解决
网站URL:http://www.wjwzjz.com/article/ggjhio.html
在线咨询
服务热线
服务热线:028-86922220
TOP