欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

SpringBoot整合MybatisPlus启动时报错: org.springframework.beans.factory.UnsatisfiedDependencyException

程序员文章站 2022-05-29 17:14:25
...

SpringBoot整合MybatisPlus在启动时直接报错
报错重点信息如下:

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.jia.vueblog.mapper.BlogMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1700) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1256) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1210) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]

可能造成报错的问题:

  • XXMapper.java 中未添加@Mapper注解或者Application主启动类中未添加@MapperScan("")注解。
  • 注解配置不完整,如Service实现类没有加@Service,Spring boot无法扫描等。
  • application.yml / application.properties中mapper-locations配置内容有误
  • @MapperScan("")注解中包路径写错
    检查发现是@MapperScan("")注解中包路径写错导致问题发生。
相关标签: 排错