报错:运行SpringBoot项目时报错APPLICATION FAILED TO START
Description:
The bean ‘person’, defined in class path resource [com/xxx/PersonConfig.class], could not be registered. A bean with that name has already been defined in file [E:\xxx\Person.class] and overriding is disabled.
Action:
Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true
因为代码中用了@Value @Bean 将配置文件的信息注入到SpringBoot容器中一次 ,然后,又用@ConfigurationProperties(prefix = “person”) @Component将配置文件的信息注入到SpringBoot容器中一次
所以就冲突了,将其中一个屏蔽掉即可。