日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學(xué)無先后,達(dá)者為師

網(wǎng)站首頁 前端文檔 正文

mapper配置xml映射錯(cuò)誤 Invalid bound statement (not found): com.springboot_jsp_shiro.dao.UserMapper.save

作者:TAIKI_daiji 更新時(shí)間: 2024-03-28 前端文檔

mapper配置踩坑記錄

我新建了一個(gè)SpringBoot工程,并打算用xml編寫mapper

這是我的文件結(jié)構(gòu)
請?zhí)砑訄D片描述
顯然,我的UserMapper.xml的路徑是resources/mapper/UserMapper.xml

我的UserMapper的路徑是com.springboot_jsp_shiro/dao/UserMapper

這是我最開始的配置

server.port=8888
server.servlet.context-path=/shiro
spring.application.name=shiro

spring.freemarker.prefix=/
spring.mvc.view.suffix=.jsp

spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/shiro?characterEncoding=UTF-8
spring.datasource.username=root
spring.datasource.password=123456

mybatis.type-aliases-package=com.springboot_jsp_shiro.entity 	#實(shí)體類映射
mybatis.mapper-locations=classpath:com/mapper/*.xml 	# xml mapper映射

我搭了一個(gè)完整的簡單業(yè)務(wù)流程,啟動(dòng)工程測試程序的可用性

但是在調(diào)用mapper的位置出現(xiàn)了這個(gè)報(bào)錯(cuò)
請?zhí)砑訄D片描述
Invalid bound statement (not found): com.springboot_jsp_shiro.dao.UserMapper.save
明顯的xml mapper映射錯(cuò)誤

隨即去檢查了xml和mapper接口的方法名

<?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.springboot_jsp_shiro.dao.UserMapper">

    <insert id="save" parameterType="User" useGeneratedKeys="true" keyProperty="id">
        insert into t_user value (#{id},#{username},#{password},#{salt});
    </insert>

</mapper>
@Mapper
public interface UserMapper {
    public int save(User user);
}

發(fā)現(xiàn)方法名是對得上的,沒有問題

然后只能去檢查配置文件,發(fā)現(xiàn)在這行出現(xiàn)了錯(cuò)誤

mybatis.mapper-locations=classpath:com/mapper/*.xml 	# xml mapper映射

但是我xml mapper的路徑壓根沒有com/ !!請?zhí)砑訄D片描述
遂修正,把路徑上的com/去掉了

mybatis.mapper-locations=classpath:mapper/*.xml

成功跑通!

原文鏈接:https://blog.csdn.net/qq_39354855/article/details/137039657

  • 上一篇:沒有了
  • 下一篇:沒有了
欄目分類
最近更新