• 首页
  • 栏目
  • ERP
  • 关于spring boot应用自动注入出现Consider defining a bean of type ‘xxx‘ in your configuration问题...

关于spring boot应用自动注入出现Consider defining a bean of type ‘xxx‘ in your configuration问题...

  • 2021-08-08
  • Admin

记录一下遇到的错误

Service、Mapper层里面的接口和类没加@service、@mapper注解,导致Spring无法将接口或者实现类扫描进容器中,导致在用到某个接口的实例化或者类的时候会在容器中找不到,就会报错

在父依赖的低版本中,可以在mapper层的接口不写@Mapper注解,不会报错

	<parent>
        <groupId>org.springframework.bootgroupId>
        <artifactId>spring-boot-starter-parentartifactId>
        <version>2.1.3.RELEASEversion>
        <relativePath/> 
    parent>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

但是在高版本的父依赖中,mapper层的接口就必须写@Mapper注解,不写就会报错

	<parent>
        <groupId>org.springframework.bootgroupId>
        <artifactId>spring-boot-starter-parentartifactId>
        <version>2.5.3version>
        <relativePath/> 
    parent>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

原文:https://blog.csdn.net/msq16021/article/details/119520502

联系站长

QQ:769220720