mybatisplus報(bào)Invalid bound statement (not found)錯(cuò)誤的解決方法
搭建項(xiàng)目時(shí)使用了mybatisplus,項(xiàng)目能夠正常啟動(dòng),但在調(diào)用mapper方法查詢數(shù)據(jù)庫時(shí)報(bào)Invalid bound statement (not found)錯(cuò)誤。
以下為項(xiàng)目配置
pom文件
<dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-extension</artifactId> <version>3.3.0</version> </dependency>
application.yml
mybatis-plus: configuration: map-underscore-to-camel-case: true # 雖然默認(rèn)為 true ,但是還是顯示去指定下。 log-impl: org.apache.ibatis.logging.stdout.StdOutImpl global-config: db-config: id-type: AUTO logic-delete-value: "Y" # 邏輯已刪除值(默認(rèn)為 Y) logic-not-delete-value: "N" #邏輯未刪除值(默認(rèn)為 N) mapper-locations: classpath*:mapper/*.xml type-aliases-package: com.test.model
啟動(dòng)類
@MapperScan(basePackages = {"com.test.dao"}) public class MyApplication { public static void main(String[] args) throws Exception { SpringApplication.run(MyApplication.class, args); } }
mapper接口
@Repository public interface PcToolMapper extends BaseMapper<PcToolNameDO> { }
PcToolNameDO實(shí)體類
@Data @TableName("pc_tool_name") public class PcToolNameDO { @TableId(value = "id", type = IdType.AUTO) private Integer id; private String pcToolName; private Date createTime; private String createUser; private Date updateTime; private String updateUser; private Long tenantId; }
出現(xiàn)問題的原因:
缺少mybatisplus的核心依賴
因?yàn)轫?xiàng)目啟動(dòng)并沒有報(bào)錯(cuò),所以沒往缺少依賴上想,項(xiàng)目中寫了mapper.xml,但沒有自定義sql,剛開始以為項(xiàng)目沒有加載mapper.xml文件,其實(shí)如果項(xiàng)目中用不到自己寫的sql語句,就沒有必要寫mqpper.xml文件,我把這個(gè)xml文件刪除了還是不行。
解決辦法:
在pom中添加mybatis的核心依賴
<dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>3.3.0</version> </dependency>
mybatis-plus-extension這個(gè)時(shí)擴(kuò)展依賴,像我在實(shí)體中使用到了@TableName注解,它是擴(kuò)展包中的,核心是mybatis-plus-boot-starter
總結(jié)
到此這篇關(guān)于mybatisplus報(bào)Invalid bound statement (not found)錯(cuò)誤的文章就介紹到這了,更多相關(guān)mybatisplus報(bào)Invalid bound statement 錯(cuò)誤內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Java利用位運(yùn)算實(shí)現(xiàn)乘法運(yùn)算詳解
這篇文章主要為大家詳細(xì)介紹了Java如何用位運(yùn)算實(shí)現(xiàn)乘法運(yùn)算,在實(shí)現(xiàn)乘法時(shí)要用位運(yùn)算實(shí)現(xiàn),并且不能出現(xiàn)加減乘除任何符號(hào),感興趣的可以了解一下2023-04-04SpringBoot接口路徑重復(fù),啟動(dòng)服務(wù)器失敗的解決
這篇文章主要介紹了SpringBoot接口路徑重復(fù),啟動(dòng)服務(wù)器失敗的解決,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2021-11-11Springboot整合EasyExcel實(shí)現(xiàn)Excel文件上傳方式
這篇文章主要介紹了Springboot整合EasyExcel實(shí)現(xiàn)Excel文件上傳方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-07-07可能是全網(wǎng)最詳細(xì)的springboot整合minio教程
MinIO是全球領(lǐng)先的對(duì)象存儲(chǔ)先鋒,在標(biāo)準(zhǔn)硬件上,讀/寫速度上高達(dá)183 GB/秒和171 GB/秒,下面這篇文章主要給大家介紹了關(guān)于springboot整合minio的相關(guān)資料,這個(gè)教程可能是全網(wǎng)最詳細(xì)的,需要的朋友可以參考下2022-06-06SpringBoot中的ApplicationRunner與CommandLineRunner問題
這篇文章主要介紹了SpringBoot中的ApplicationRunner與CommandLineRunner問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-09-09Springboot與vue實(shí)例講解實(shí)現(xiàn)前后端分離的人事管理系統(tǒng)
這篇文章主要介紹了如何用Java實(shí)現(xiàn)企業(yè)人事管理系統(tǒng),文中采用springboot+vue實(shí)現(xiàn)前后端分離,感興趣的小伙伴可以學(xué)習(xí)一下2022-06-06Java中Stream流對(duì)多個(gè)字段進(jìn)行排序的方法
我們?cè)谔幚頂?shù)據(jù)的時(shí)候經(jīng)常會(huì)需要進(jìn)行排序后再返回給前端調(diào)用,比如按照時(shí)間升序排序,前端展示數(shù)據(jù)就是按時(shí)間先后進(jìn)行排序,下面這篇文章主要給大家介紹了關(guān)于Java中Stream流對(duì)多個(gè)字段進(jìn)行排序的相關(guān)資料,需要的朋友可以參考下2023-10-10