zoukankan      html  css  js  c++  java
  • SpringBoot:SpringBoot和SpringCloud版本匹配问题导致Bean冲突问题

    报错信息

    Error starting ApplicationContext. To display the conditions report re-run your application with ‘debug’ enabled.
    2020-09-17 16:34:52.056 ERROR 19128 — [ main] o.s.b.d.LoggingFailureAnalysisReporter :

    APPLICATION FAILED TO START

    Description:

    The bean ‘dataSource’, defined in BeanDefinition defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfigurationHikari.class],could not beregistered. A bean with that name hasal ready been defined in classpath resource[org/springframework/boot/autoconfigure/jdbc/DataSourceConfigurationHikari.class], could not be registered. A bean with that name has already been defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfigurationHikari.class],could not beregistered. A bean with that name hasal ready been defined in classpath resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfigurationHikari.class] and overriding is disabled.

    Action:

    Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true

    Disconnected from the target VM, address: ‘127.0.0.1:62029’, transport: ‘socket’

    Process finished with exit code 1
    ————————————————

     从错误信息中可以看到,dataSource这个bean已经被register(注册)了。

    解决方法

    配置文件中加入如下配置

    # 设置为true时,后定义的bean会覆盖之前定义的相同名称的bean
    spring.main.allow-bean-definition-overriding=true

    #注:spring中默认是true,也就是默认支持名称相同的bean的覆盖。而springboot中的默认值是false,也就是不支持名称相同的bean被覆盖。

    根本原因分析

    终究原因后面发现是SpringBoot和SpringCloud版本匹配问题导致的;把版本降下来后,问题自然解决了,这才是推荐方案,从根本上解决。

    文章转载至:https://blog.csdn.net/weixin_39098944/article/details/108647058

    ----------------------------------- 作者:怒吼的萝卜 链接:http://www.cnblogs.com/nhdlb/ -----------------------------------
  • 相关阅读:
    UIStepper
    UIProgressView
    Python——GUI编程 利息计算器 作业9(python programming)
    Python——GUI编程(python programming)
    麻烦的聚餐(最长递增子序列+二分优化)
    奶牛渡河(dp)
    POJ 1182-食物链 [并查集] 《挑战程序设计竞赛》2.4
    [2013百度软件研发笔试题] 求字符串中连续出现同样字符的最大值
    Java OCR tesseract 图像智能字符识别技术
    ORA-00904:"T1"."AREA_ID" :标识符无效
  • 原文地址:https://www.cnblogs.com/nhdlb/p/15660022.html
Copyright © 2011-2022 走看看