[Bug0006]Consider defining a bean of type ‘*Mapper‘ in your configuration.

问题

Consider defining a bean of type ‘*Mapper‘ in your configuration.

原因

在使用新的mybatis时,使用注解@Mapper修饰相应的mapper接口,但是在controller里不能使用@Autowired自动注入,报错
Consider defining a bean of type '*Mapper' in your configuration.

解决方案

在启动类里添加注解@ComponentScan,里面的路径是对应的mapper路径

实例

@SpringBootApplication
@ComponentScan({"com.lll.blog.admin.mapper"})
public class AdminApp {

}

posted @ 2022-04-18 22:09  Code7Rain  阅读(234)  评论(0编辑  收藏  举报