tk.mapper(通用mapper)出现的问题:Error invoking SqlProvider method (tk.mybatis.mapper.provider.SpecialProvid

今天在SpringBoot上集成tk.mapper出现如下错误:

Error invoking SqlProvider method (tk.mybatis.mapper.provider.SpecialProvider.dynamicSQL)
java.lang.NoSuchMethodException: tk.mybatis.mapper.provider.SpecialProvider.()
Caused by: org.apache.ibatis.builder.BuilderException: Error invoking SqlProvider method (tk.mybatis.mapper.provider.base.BaseSelectProvider.dynamicSQL).  Cause: java.lang.InstantiationException: tk.mybatis.mapper.provider.base.BaseSelectProvider
	at org.apache.ibatis.builder.annotation.ProviderSqlSource.createSqlSource(ProviderSqlSource.java:134) ~[mybatis-3.4.6.jar:3.4.6]
	at org.apache.ibatis.builder.annotation.ProviderSqlSource.getBoundSql(ProviderSqlSource.java:102) ~[mybatis-3.4.6.jar:3.4.6]
	at org.apache.ibatis.mapping.MappedStatement.getBoundSql(MappedStatement.java:292) ~[mybatis-3.4.6.jar:3.4.6]
	at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:81) ~[mybatis-3.4.6.jar:3.4.6]
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:148) ~[mybatis-3.4.6.jar:3.4.6]
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141) ~[mybatis-3.4.6.jar:3.4.6]
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:77) ~[mybatis-3.4.6.jar:3.4.6]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_60]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_60]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_60]
	at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_60]
	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433) ~[mybatis-spring-1.3.2.jar:1.3.2]
	... 58 more

查阅相关资料,通常是通用 Mapper 没有配置好,没有对 MyBatis 方法初始化造成的。常见的判断方法就是看看其他非 Example 的通用方法能否执行,如果不能执行就是配置的问题。如果能正常执行,可能就是第二种情况。
参考资料:通用Mapper问题
处理方式:
将SpringBoot 启动类中的@MapperScan 注解引入的包由

org.mybatis.spring.annotation.MapperScan

替换成:

tk.mybatis.spring.annotation.MapperScan

引入的依赖为:

     
        
            tk.mybatis
            mapper-spring-boot-starter
            2.0.2
        

你可能感兴趣的:(MyBatis)