错误信息:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘com.atguigu.mybatis_plus.MybatisPlusApplicationTests’: Unsatisfied dependency expressed through field ‘userMapper’; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘com.atguigu.mybatis_plus.mapper.UserMapper’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘com.atguigu.mybatis_plus.mapper.UserMapper’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
他说找不到我哪个类,我觉得可能是ioc出了问题,但是我已经加了spring的注解
解决:
实际是Mybatis-plus没有找到我的类路径,需要在启动类中加@MapperScan(“com.atguigu.mybatis_plus.mapper”)