容器未找到bean,Field usersMapper in com.imooc.impl.UserServiceImpl required a bean of type 'com.imoo
启动报未找到相关的实体类错误
Description:
Field usersMapper in com.imooc.impl.UserServiceImpl required a bean of type 'com.imooc.mapper.UsersMapper' that could not be found.
The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)
Action:
Consider defining a bean of type 'com.imooc.mapper.UsersMapper' in your configuration.
原因可是是启动类扫描包范围问题,需要加上对应报错类的包路径的注解
import tk.mybatis.spring.annotation.MapperScan; @SpringBootApplication @MapperScan("com.imooc.mapper") public class Application { public static void main(String[] args) { SpringApplication.run(Application.class,args); } }