Error Messages:
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
————————————————
From the error message, we can see that the bean dataSource has been registered.
Solution:
Add the following configuration to the configuration file
# When set to true, a later defined bean will override a previously defined bean with the same name
spring.main.allow-bean-definition-overriding=true
#Note: The default in spring is true, which means that overriding of beans with the same name is supported by default. The default value in springboot is false, which means that beans with the same name are not supported to be overridden.
Root cause analysis
After all, it was found that the problem was caused by the version matching between springboot and springcloud; After the version is lowered, the problem is solved naturally. This is the recommended solution, which is fundamentally solved.