Spring boot allowBeanDefinitionOverriding

1、问题

启动异常

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-07-24 17:08:33.330 ERROR 15684 --- [           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/DataSourceConfiguration$Hikari.class], could not be registered. A bean with that name has already been defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class] and overriding is disabled.
Action:
Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true
Process finished with exit code 1

2、原因分析:

spring boot 2.1.0 默认情况下禁用Bean覆盖,导致启动时候出现异常

3、解决方案:在application.yml中手动打开即可,如下

spring:
  main:
    allow-bean-definition-overriding: true

 

你可能感兴趣的:(系统架构,Spring)