MybatisPlus读不到mapper

SpringBoot3.1.3使用MybatisPlus出现了读不到mapper的问题,但检查一下没发现扫码问题

  • error
    org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.ysd.if_java.mapper.UserMapper.getOneByUserId

mapper有加@mapper;JavaApplication有加@MapperScan("com.ysd.if_java.mapper")

  • pom.xml
mybatis-plus:
  configuration:
    # 是否开启自动驼峰命名规则(camel case)映射
    map-underscore-to-camel-case: true
    # 这个配置会将执行的sql打印出来,在开发或测试的时候可以用
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
  # MyBaits 别名包扫描路径,通过该属性可以给包中的类注册别名
  type-aliases-package: com.ysd.if_java.domain
  # xml扫描,多个目录用逗号或者分号分隔(告诉 Mapper 所对应的 XML 文件位置)
  mapper-locations: classpath:mapper/*.xml
  global-config:
    banner: off
  • mapper.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ysd.if_java.mapper.UserMapper">

    <resultMap id="BaseResultMap" type="com.ysd.if_java.domain.User">
            <id property="userId" column="userId" jdbcType="INTEGER"/>
            <result property="userName" column="userName" jdbcType="VARCHAR"/>
            <result property="userPassword" column="userPassword" jdbcType="VARCHAR"/>
            <result property="userEmail" column="userEmail" jdbcType="VARCHAR"/>
            <result property="userPhone" column="userPhone" jdbcType="BIGINT"/>
            <result property="roleId" column="roleId" jdbcType="INTEGER"/>
            <result property="companyId" column="companyId" jdbcType="INTEGER"/>
            <result property="sectorId" column="sectorId" jdbcType="INTEGER"/>
    </resultMap>

    <sql id="Base_Column_List">
        userId,userName,userPassword,
        userEmail,userPhone,roleId,
        companyId,sectorId
    </sql>

    <select id="getOneByUserId" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from tbl_user
        where
        userId = #{userId,jdbcType=NUMERIC}
    </select>

</mapper>

这个时Spring3+独有的问题,我把版本降到2.7.5就没问题了;以下时完整代码:

  • domain

img

  • mapper

img

-mapper.xml

img

  • test

img

  • 目录结构

img

  • application.yml

img

【相关推荐】




如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^