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

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 协议》,转载必须注明作者和本文链接
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!