• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

ServiceImpl层引入Mapper方法失败问题的解决

武飞扬头像
moxiaoran5753
帮助3

ServiceImpl层引入Mapper方法注入失败,项目一启动就报异常:

Caused by: org.apache.ibatis.binding.BindingException: Invalid bound statement

[main] ERROR o.s.b.SpringApplication - [reportFailure,824] - Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sysJobController': Unsatisfied dependency expressed through field 'jobService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sysJobServiceImpl': Invocation of init method failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.yio.job.mapper.SysJobMapper.selectJobAll at ...........

检查了启动类,已经加了MapperScan注解

@MapperScan("com.yio.**.mapper")

再去看配置文件,

  1.  
    # mybatis配置
  2.  
     
  3.  
    mybatis:
  4.  
     
  5.  
    # 搜索指定包别名
  6.  
     
  7.  
    typeAliasesPackage: com.yio.agent
  8.  
     
  9.  
    # 配置mapper的扫描,找到所有的mapper.xml映射文件
  10.  
     
  11.  
    mapperLocations: classpath:mapper/**/*.xml

反复检查了多次,代码层面和配置文件均未发现有问题,后面就有点怀疑是resources里边目录定义的问题,先来对比一下resources里边层级结构,先来看启动正常的,

学新通

再来看启动报错的,

学新通

 乍一看,感觉结构一样啊,没什么问题。

再来看编译以后的结构,也就是target里边的层级结构

先来看正常的:

学新通

有问题的:

学新通

 这么一对比,发现了吧,有问题这个编译后没有层级缩进,而是以点号并排在前面目录的后面。问题恰恰就出现在这里,原来如果想在resources建立多级,建立完mapper文件夹之后,继续在resources 上面右键新建目录,输入为 mapper/newDir用 / 分开就可以设置多个.而不是在mapper目录上右键新建Directory。

调整后启动终于正常了。

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhfckhie
系列文章
更多 icon
同类精品
更多 icon
继续加载