org.apache.ibatis.binding.BindingException:?Invalid bound statement (not found): com.xxx.xxx.service.CitytownService.selectCitytown
出現無法加載sevice層的時候,如下圖所示

1,處理方法是,先看下注解@MapperScan內的包地址,是不是指定到dao層或mapper層。

2,如果上述正確,那么再看mybatisplus依賴是否導入正確,如圖:
<dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-boot-starter</artifactId><version>對應版本號,與你的springboot兼容的版本</version>
</dependency>
<dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-generator</artifactId><version>對應版本號,與你的springboot兼容的版本</version>
</dependency>
3,再看配置mybatis或mybatisplus的配置文件,yml如下:
mybatis-plus:mapper-locations: classpath*:mapper/*.xmltype-aliases-package: com.xxx.xxx.entityglobal-config:db-config:id-type: autoconfiguration:map-underscore-to-camel-case: truelog-impl: org.apache.ibatis.logging.stdout.StdOutImpl//這里是執行過程的log日志打印
application.properties 配置如下
mybatis-plus.mapper-locations=classpath:mapper/*.xml
mybatis-plus.type-aliases-package=com.xxx.xxx.entity//或者是pojo,也就是實體類
4,都沒問題了。問題就解決了。測試執行成功
