[已解决]Invalid bound statement (not found): com.atdession.service.UserService.getBaseMapper

目录

错误提示

错误原因

解决


错误提示

在使用SpringBoot整合mybatisplus的时候,在数据库和controller联调的时候,发现这个错误。

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.atdession.service.UserService.getBaseMapper
    at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:235) ~[mybatis-3.5.9.jar:3.5.9]
    at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.<init>(MybatisMapperMethod.java:50) ~[mybatis-plus-core-3.5.1.jar:3.5.1]
    at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.lambda$cachedInvoker$0(MybatisMapperProxy.java:111) ~[mybatis-plus-core-3.5.1.jar:3.5.1]
    at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660) ~[na:1.8.0_362]
    at com.baomidou.mybatisplus.core.toolkit.CollectionUtils.computeIfAbsent(CollectionUtils.java:115) ~[mybatis-plus-core-3.5.1.jar:3.5.1]
    at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.cachedInvoker(MybatisMapperProxy.java:98) ~[mybatis-plus-core-3.5.1.jar:3.5.1]
    at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:89) ~[mybatis-plus-core-3.5.1.jar:3.5.1]
    at com.sun.proxy.$Proxy57.getBaseMapper(Unknown Source) ~[na:na]
    at com.baomidou.mybatisplus.extension.service.IService.getById(IService.java:292) ~[mybatis-plus-extension-3.5.1.jar:3.5.1]
    at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:627) ~[na:1.8.0_362]

错误原因

MapperScan要扫描到指定的包下

@SpringBootApplication
#错误:要扫描指定的mapper包下
@MapperScan(basePackages = "com.atdession")
public class BillMain {

    public static void main(String[] args) {
        SpringApplication.run(BillMain.class,args);
    }
}

解决

因为我MapperScan扫描的时候是全盘扫描,将MapperScan指定扫描Mapper包即可

@SpringBootApplication
@MapperScan(basePackages = "com.atdession.mapper")
public class BillMain {

    public static void main(String[] args) {
        SpringApplication.run(BillMain.class,args);
    }
}

解决啦

猜你喜欢

转载自blog.csdn.net/wang20000102/article/details/132569309