java.lang.NoSuchMethodException: tk.mybatis.mapper.provider.SpecialProvider.()

时间:2024-01-17 08:15:32
Caused by: org.apache.ibatis.builder.BuilderException: Error invoking SqlProvider method (tk.mybatis.mapper.provider.SpecialProvider.dynamicSQL).  Cause: java.lang.InstantiationException: tk.mybatis.mapper.provider.SpecialProvider
at org.apache.ibatis.builder.annotation.ProviderSqlSource.createSqlSource(ProviderSqlSource.java:135) ~[mybatis-3.4.5.jar:3.4.5]
at org.apache.ibatis.builder.annotation.ProviderSqlSource.getBoundSql(ProviderSqlSource.java:103) ~[mybatis-3.4.5.jar:3.4.5]
at org.apache.ibatis.mapping.MappedStatement.getBoundSql(MappedStatement.java:292) ~[mybatis-3.4.5.jar:3.4.5]
at org.apache.ibatis.executor.statement.BaseStatementHandler.<init>(BaseStatementHandler.java:64) ~[mybatis-3.4.5.jar:3.4.5]
at org.apache.ibatis.executor.statement.PreparedStatementHandler.<init>(PreparedStatementHandler.java:40) ~[mybatis-3.4.5.jar:3.4.5]
at org.apache.ibatis.executor.statement.RoutingStatementHandler.<init>(RoutingStatementHandler.java:46) ~[mybatis-3.4.5.jar:3.4.5]
at org.apache.ibatis.session.Configuration.newStatementHandler(Configuration.java:558) ~[mybatis-3.4.5.jar:3.4.5]
at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:48) ~[mybatis-3.4.5.jar:3.4.5]
at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117) ~[mybatis-3.4.5.jar:3.4.5]
at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:76) ~[mybatis-3.4.5.jar:3.4.5]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_191]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_191]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_191]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_191]
at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:63) ~[mybatis-3.4.5.jar:3.4.5]
at com.sun.proxy.$Proxy269.update(Unknown Source) ~[na:na]
at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:198) ~[mybatis-3.4.5.jar:3.4.5]
at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:185) ~[mybatis-3.4.5.jar:3.4.5]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_191]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_191]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_191]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_191]
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433) ~[mybatis-spring-1.3.1.jar:1.3.1]
... 117 common frames omitted
Caused by: java.lang.InstantiationException: tk.mybatis.mapper.provider.SpecialProvider
at java.lang.Class.newInstance(Class.java:427) ~[na:1.8.0_191]
at org.apache.ibatis.builder.annotation.ProviderSqlSource.createSqlSource(ProviderSqlSource.java:117) ~[mybatis-3.4.5.jar:3.4.5]
... 139 common frames omitted
Caused by: java.lang.NoSuchMethodException: tk.mybatis.mapper.provider.SpecialProvider.<init>()
at java.lang.Class.getConstructor0(Class.java:3082) ~[na:1.8.0_191]
at java.lang.Class.newInstance(Class.java:412) ~[na:1.8.0_191]
... 140 common frames omitted

tk.mybatis中,如果继承了MySqlMapper<T>

里面源码

@RegisterMapper
public interface MySqlMapper<T> extends InsertListMapper<T>, InsertUseGeneratedKeysMapper<T> {
}

使用 InsertListMapper<T>接口的insertList<T>方法时报错

需要修改MapperScan

应该引入的包是:tk.mybatis.spring.annotation.MapperScan;

我这边报错  是因为我集成tk.mybatis,然后没有修改这个地方,

原先引入的包是:org.mybatis.spring.annotation.MapperScan;

修改好,亲测有效了。

如果不使用insertList 也不会报错,有需要的就改下这个地方。
java.lang.NoSuchMethodException: tk.mybatis.mapper.provider.SpecialProvider.<init>()

我这个是两个数据源,所以在这个配置文件里面的,如果是单个数据源,直接在启动主类里面 改就好了
java.lang.NoSuchMethodException: tk.mybatis.mapper.provider.SpecialProvider.<init>()

https://blog.csdn.net/dxiaol/article/details/81702882