前言
因为最近在学习一个教程,项目搭建采用 spring boot + mybatis 使用mybatis的都知道mybatis的逆向工程,但是这个项目采用一个开源的逆向工程地址奉上MyBatis 通用 Mapper4但是我在使用的时候疯狂报错来看看我怎么解决的。
正文
首先错误如下
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Tue May 19 10:15:46 CST 2020
There was an unexpected error (type=Internal Server Error, status=500).
nested exception is org.apache.ibatis.builder.BuilderException: Error invoking SqlProvider method 'public java.lang.String tk.mybatis.mapper.mapperhelper.MapperTemplate.dynamicSQL(java.lang.Object)' with specify parameter 'class java.lang.Integer'. Cause: java.lang.NoSuchMethodException: tk.mybatis.mapper.provider.base.BaseSelectProvider.<init>()
访问不使用mapper的接口正常但是访问使用mapper的接口则一直报错,
于是乎我百度了众多的博主发现一个问题。
需要用MapperScan来指定你存放mapper的位置,一开始我使用的是
import org.mybatis.spring.annotation.MapperScan(错误引用)
但是实际应该使用
import tk.mybatis.spring.annotation.MapperScan(正确的引用包)
于是我很高兴的点了run结果呢,错误还是雷打不动,最后一路跟着百度我找到了他的git地址,然后详细的阅读了一下spring boot 如何集成这个通用mapper最后尝试性的在我的application.yml 加上了
mapper:
mappers:
tk.mybatis.mapper.common.Mapper
点击run输入url错误解决。
那些我踩过的坑,害。