The bean 'dataSource', defined in BeanDefinition defined in class path resource

問題:
啓動SpringBoot項目報錯:

***************************
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

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-01-11 10:55:38.248 ERROR 12708 --- [           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


原因:
SpringBoot和SpringCloud的版本不兼容造成。
這裏因爲SpringBoot想嚐鮮使用了2.1.1,而SpringCloud仍然用的是Finchley.SR2,而它支持的是2.0.x及以下版本。
對應的版本應該使用Greenwich.M1。
Issues回答:

解決:
降SpringBoot版本或者使用Greenwich.M1。
所以還是建議直接在start.spring.io上構建新項目,或者在idea上構建項目的時候選擇Spring Initializr來避免版本不兼容。
--------------------- 
原文:https://blog.csdn.net/u012211603/article/details/83714285 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章