Annotation-specified bean name ‘mapper‘ for bean class [] conf

时间:2025-02-14 21:59:45

项目集成 eureka 和 mybatis-plus 的时候,出现了注解同名注入的冲突,原因是 mybatis-spring 扫描的包不对

  • 错误信息:
    Annotation-specified bean name 'mapper' for bean class [] conflicts with existing, non-compatible bean definition of same name and class []

  • 原有注解扫描的范围太大了,扫描到了依赖包

@MapperScan("com.**.mapper*")
  • 将包的范围改小就好了
@MapperScan(".**.mapper*")