org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userServiceImpl': Unsatisfied dependency expressed through field 'baseMapper': No qualifying bean of type 'com.weblog.auth.mapper.UserMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: { .springframework.beans.factory.annotation.Autowired(required=true)} Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.weblog.auth.mapper.UserMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: { .springframework.beans.factory.annotation.Autowired(required=true)}
错误:org.springframework.beans.factory.NoSuchBeanDefinitionException
。没有在factory找到已经定义的bean
解释:No qualifying bean of type 'XXXX' available
。具体是哪一个没有找到,根据com.weblog.auth.mapper.UserMapper
找到提示的包
引起原因:在使用自动注入的时候,没有找到对应的bean
解决方案:
- 在对应的Mapper上添加
@Mapper
注解
- 在启动类上添加
@MapperScan
注解,指定到mapper所在的文件夹(推荐)