• springboot 项目启动报注册重复, A bean with that name has already been defined and overridin


    springboot 启动时由于多次注册了同一个bean,导致报错: A bean with that name has already been defined and overridin

    可能产生的原因:
    0、启动类application都是自动扫描本包及其以下的包。就是application主类
    1、@MapperScan("mapper的位置"),这里扫包,扫了一次加入bean中。
    2、其他方式又加载注入这个同名的bean。
    Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
    2020-04-23 10:22:50.810  INFO [my-server-search,,,] 33172 --- [           main] com.netflix.discovery.DiscoveryClient    : Shutting down DiscoveryClient ...
    2020-04-23 10:22:50.833  INFO [my-server-search,,,] 33172 --- [           main] com.netflix.discovery.DiscoveryClient    : Completed shut down of DiscoveryClient
    2020-04-23 10:22:50.837 ERROR [my-server-search,,,] 33172 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 
    
    ***************************
    APPLICATION FAILED TO START
    ***************************
    
    Description:
    
    The bean 'my-server-cms.FeignClientSpecification' could not be registered. A bean with that name has already been defined and overriding is disabled.
    
    Action:
    
    Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true

    在application.yml中加上如下配置问题解决

    spring:
     main:
        allow-bean-definition-overriding: true    #当遇到同样名字的时候,是否允许覆盖注册不配置会报错 
  • 相关阅读:
    Python调用sqlAlchemy
    Docker容器管理及代码调用
    Spring设置动态定时任务
    多数据源实现读写分离
    Spring整合EHCache框架
    springBoot整合Redis
    初探Mybaties整合分页插件PageHelper(1)
    流程控制,循环结构,for,while循环
    变量,常量,格式化输入输出,运算符
    编程语言介绍,变量介绍
  • 原文地址:https://www.cnblogs.com/a393060727/p/12759019.html
Copyright © 2020-2023  润新知