springboot在配置Bean的時候,可能會出現這樣的錯誤!!! 原因是因為相同名字的bean已經存在了。
***************************
APPLICATION FAILED TO START
***************************
Description:
The bean 'interceprot', defined in class path resource [com/example/demo1/doInterceptor.class], could not be registered. A bean with that name has already been defined in file [/Users/sun/Desktop/demo1/target/classes/com/example/demo1/Interceprot.class] and overriding is disabled.
Action:
Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true
要是想配置成功,需要在配置檔案中加上這樣一段
spring.main.allow-bean-definition-overriding=true
意思是覆蓋bean。 這樣就好了!!!!
本作品採用《CC 協議》,轉載必須註明作者和本文連結