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.
Similar Posts:
- [Solved] ShardingJDBC Error: The bean ‘dataSource’, defined in class path resource [org/apache/shardingsphere/shardingjdbc/spring/boot/SpringBootConfiguration.class], could not be registered.
- [Solved] Feign Error: The bean ‘xxxxx.FeignClientSpecification’ could not be registered.
- Unit test reports an error nosuchbeandefinitionexception
- [Solved] The swagger UI dependency is introduced into spring boot Error
- [Solved] springboot Startup Error: Bean with name ‘xxxxService‘ has been injected into other beans
- [Solved] org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘deptController’: Unsatisfied dependency expressed through field ‘departmentMapper
- How to Solve the login error of Spring + Shiro CacheManager
- org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘configurationPropertiesBeans’ defined in class path resource
- Springcloud: gateway module startup error
- Cannot find the declaration of element ‘beans’