mapper目录无法被扫描到

mapper目录无法被扫描到

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.bfxy.rabbit.producer.mapper.BrokerMessageMapper.selectByPrimaryKey

http://img1.sycdn.imooc.com//climg/5eedc9de09791ece10390372.jpghttp://img1.sycdn.imooc.com//climg/5eedc9be09aad21410010089.jpg

正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

5回答
qq_范特西_8 2023-03-14 13:01:26

在你的最外层pom里边加上这个


<!--    <build>-->
<!--      <resources>-->
<!--         <resource>-->
<!--            <directory>src/main/java</directory>-->
<!--            <includes>-->
<!--               <include>**/*.xml</include>-->
<!--            </includes>-->
<!--            <filtering>false</filtering>-->
<!--         </resource>-->

<!--         <resource>-->
<!--            <directory>src/main/resources</directory>-->
<!--            <includes>-->
<!--               <include>**/*.xml</include>-->
<!--               <include>**/*.properties</include>-->
<!--               <include>**/*.sql</include>-->
<!--            </includes>-->
<!--            <filtering>false</filtering>-->
<!--         </resource>-->
<!--      </resources>-->
<!--   </build>-->

然后解开注释

被一个苹果砸到的我 2021-02-06 19:11:50

代码里指定了mapping路径,把mapping改到resource目录下,代码里也改一下就ok了

阿伟快没头发了 2020-07-18 21:59:11

把mapping 放在resources下   我改名为mapper

然后

http://img1.sycdn.imooc.com//climg/5f13002c099e38a209790205.jpg

求知饥虚心愚 2020-07-07 17:30:39

解决了吗?我也扫描不到

  • 我也是这个问题 你怎么弄的

    2020-12-16 00:19:29
阿神 2020-06-20 19:34:43

仔细看一下,是否加了包路径扫描,是不是少写了什么呢

  • 提问者 叁哥的秘密 #1
    我用git仓下的代码 试了一下还是这样 不过我用的是用IDEA
    2020-06-20 21:07:16
  • 提问者 叁哥的秘密 #2
    代码仓中的工程代码在eclipse中的.classpath制定了classpath, 所以我将xml扫描路径修改为classpath*,但是后面debug追踪,发现依旧是sqlSession.getConfiguration,mappedStatements中没有对应的statements,不知道是不是因为eclipse打包的工程,是不是根据.classpath配置扫描mapper的路径,如果用IDEA打开有的兼容性问题
    2020-06-20 21:32:47
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师