1. 程式人生 > 其它 >springboot啟動類報錯

springboot啟動類報錯

技術標籤:日常擼碼

問題:

Caused by: org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'gatewayLoggerProfile' for bean class [com.common.config.GatewayLoggerProfile] conflicts with existing, non-compatible bean definition of same name and class [com.gateway.config.GatewayLoggerProfile]
	at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.checkCandidate(ClassPathBeanDefinitionScanner.java:348)
	at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:286)
	at org.springframework.context.annotation.ComponentScanAnnotationParser.parse(ComponentScanAnnotationParser.java:132)
	at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:287)
	at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:242)
	at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:199)
	at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:167)
	... 13 common frames omitted

原因:

啟動類裡面,掃描的東西太泛了(太多了),這個名字的找到了兩個同名檔案,所以啟動報錯。

解決辦法

1:掃包具體到某一個要掃描的package上

2:重名檔案修改檔名

3:重名檔案內分別命名