<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.7.RELEASE</version> </parent>
<dependency> <groupId>tk.mybatis</groupId> <artifactId>mapper-spring-boot-starter</artifactId> <version>1.1.0</version> </dependency>项目使用spring boot1.5.7 集成mybatis通用mapper插件,发现查询方法selectByPrimaryKey
会导致发生异常—— java.lang.ClassCastException:com.xxx.xxx.entity cannot be cast to com.xxx.xxx.entity
insert、update、delete方法都没有问题,就是查询出实体就报异常。
select这是插件的一个bug
解决方法如下:在spring boot项目resources目录下创建一个META-INF文件夹,在META-INF目录下再创建一个
spring-devtools.properties 文件
加入以下代码即可解决
restart.include.companycommonlibs=tk/mybatis.*