Stories

Detail Return Return

在spring框架中mybatis可能會遇到的錯誤 - Stories Detail

聲明環境

數據庫:MySQL8.0
springboot框架:使用阿里雲的腳手架
Java:17

常見錯誤

MySQL密碼錯誤

image.png
數據庫密碼錯了,到你的application.properties配置文件檢查一下你的MySQL密碼是否輸錯了

找不到數據庫

image.png
找不到數據庫,到你的application.properties配置文件檢查一下你的數據庫是不是填錯了或少打多打都用可能

找不到表

image.png
找到出錯包下的xml文件,看一下你的表是不是寫錯了

BindingException

綁定異常
image.png
StudentMapper.selectClazz沒有找到對應的SQL語句
看一下StudentMapper映射的xml文件有沒有錯誤
image.png

空指針異常

image.png
image.png
沒有加autowired註解,加一下就行了

TooManyResultsException

太多結果異常,意思期望返回的是一個結果或空的,但是找到多條數據
解決辦法:
image.png
找到錯誤的行數,我的錯誤在test測試的159行,找的原來的方法,把它改成list集合就不會報錯了
image.png

user avatar u_17513518 Avatar u_16769727 Avatar u_11365552 Avatar zzzzbw Avatar lu_lu Avatar linybjikezhilu Avatar boxuegu Avatar lvweifu Avatar xiongshihubao Avatar pottercoding Avatar qqxx6661 Avatar wuxiedekeben Avatar
Favorites 24 users favorite the story!
Favorites

Add a new Comments

Some HTML is okay.