網(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)
顯然,我的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ò)
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/ !!
遂修正,把路徑上的com/去掉了
mybatis.mapper-locations=classpath:mapper/*.xml
成功跑通!
原文鏈接:https://blog.csdn.net/qq_39354855/article/details/137039657
- 上一篇:沒有了
- 下一篇:沒有了
相關(guān)推薦
- 2023-04-20 for循環(huán)生成表單,表單校驗(yàn)失效
- 2022-08-19 Spring Cloud Config配置服務(wù)
- 2023-06-19 Python機(jī)器學(xué)習(xí)之隨機(jī)梯度下降法的實(shí)現(xiàn)_python
- 2024-02-01 webstorm中Line comment at first column,Block commen
- 2022-12-11 Redis?Cluster原理及配置詳解_Redis
- 2021-11-27 關(guān)于UDP服務(wù)器客戶端編程流程介紹_C 語言
- 2022-11-22 Android本地存儲方法淺析介紹_Android
- 2022-09-15 C語言實(shí)現(xiàn)通訊錄系統(tǒng)課程設(shè)計(jì)_C 語言
- 欄目分類
-
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細(xì)win安裝深度學(xué)習(xí)環(huán)境2025年最新版(
- Linux 中運(yùn)行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎(chǔ)操作-- 運(yùn)算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認(rèn)證信息的處理
- Spring Security之認(rèn)證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權(quán)
- redisson分布式鎖中waittime的設(shè)
- maven:解決release錯(cuò)誤:Artif
- restTemplate使用總結(jié)
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實(shí)現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務(wù)發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結(jié)構(gòu)-簡單動(dòng)態(tài)字符串(SD
- arthas操作spring被代理目標(biāo)對象命令
- Spring中的單例模式應(yīng)用詳解
- 聊聊消息隊(duì)列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠(yuǎn)程分支