前言
項(xiàng)目使用Spring Boot1.5.2 集成Mybatis通用mapper插件膘滨,發(fā)現(xiàn)查詢方法selectByPrimaryKey,會(huì)導(dǎo)致類型轉(zhuǎn)換錯(cuò)誤
會(huì)導(dǎo)致發(fā)生異常
java.lang.ClassCastException:com.xxx.xxx.entity cannot be cast to com.xxx.xxx.entity
經(jīng)測(cè)試:insert、update絮识、delete方法都沒(méi)有問(wèn)題妹孙,就是查詢出實(shí)體就報(bào)異常唆阿。后來(lái)到github看到這是插件的一個(gè)bug
解決方法如下:
在spring boot項(xiàng)目resources目錄下創(chuàng)建一個(gè)META-INF文件夾暖夭,在META-INF目錄下再創(chuàng)建一個(gè) spring-devtools.properties 文件睦授,加入以下代碼即可解決
restart.include.companycommonlibs=tk/mybatis.*