The bean ‘xxx‘, defined in class path resource , ……

Time:2021-1-20

When spring boot configures bean, there may be such an error!!! The reason is that a bean with the same name already exists.

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

If you want to configure successfully, you need to add such a paragraph in the configuration file

spring.main.allow-bean-definition-overriding=true

This means to override the bean. That’s it!!!!

This work adoptsCC agreementReprint must indicate the author and the link of this article