在使用mybatis-plus代码生成时,启动项目发现的bug
No qualifying bean of type 'com.aqya.mapper.UserMapper' available
没有可用的“com.aqya.mapper.UserMapper”类型的合格 bean
Unsatisfied dependency expressed through field 'baseMapper'
通过字段“baseMapper”表示的不满足的依赖关系问题
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userController': Unsatisfied dependency expressed through field 'userService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userServiceImpl': Unsatisfied dependency expressed through field 'baseMapper'; nested exception is {@org.springframework.beans.factory.annotation.Autowired(required=true)}
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.aqya.mapper.UserMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations:
这里要检查Mapper接口代码没有进行@Mapper映射。
也可以在Application中进行@MapperScan("com.xxx")
也可以在代码生成器
strategyConfig 加入
builder.mapperBuilder().enableMapperAnnotation().build();//mapper注解