1. 程式人生 > 實用技巧 >springboot 啟動報錯: Multiple Dockets with the same group name are not supported. The following duplicat

springboot 啟動報錯: Multiple Dockets with the same group name are not supported. The following duplicat

報錯詳情

org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.IllegalStateException: Multiple Dockets with the same group name are not supported. The following duplicate groups were discovered. default

.....

Caused by: java.lang.IllegalStateException: Multiple Dockets with the same group name are not supported. The following duplicate groups were discovered. default

截圖

org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.IllegalStateException: Multiple Dockets with the same group name are not supported. The following duplicate groups were discovered. default
	at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:185)
	at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:53)
	at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:360)
	at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:158)
	at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:122)
	at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:894)
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:162)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:553)
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)
	at com.lucas.template.TemplateApplication.main(TemplateApplication.java:18)
Caused by: java.lang.IllegalStateException: Multiple Dockets with the same group name are not supported. The following duplicate groups were discovered. default
	at springfox.documentation.spring.web.plugins.DuplicateGroupsDetector.ensureNoDuplicateGroups(DuplicateGroupsDetector.java:45)
	at springfox.documentation.spring.web.plugins.DocumentationPluginsManager.documentationPlugins(DocumentationPluginsManager.java:97)
	at springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper.start(DocumentationPluginsBootstrapper.java:162)
	at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:182)
	... 14 common frames omitted

查詢原因

在網上根據這個報錯搜尋了一番,各種答案都和我這個好像沒有關係,而且他們的解答好像都是複製了,都沒說明原因

那就只能自己想辦法解決,報錯解釋:不支援具有相同組名的多個文件。發現以下重複組。default

完全沒有頭緒,default ,然後mvn pakcage -X 打包查詢也是相同的錯誤,沒有更詳細的原因,

問題點

根據報錯提供的 documentationPluginsBootstrapper 和 DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:185) 和 報錯列印

找到 DefaultLifecycleProcessor 中丟擲異常的地方,找到

DocumentationPluginsBootstrapper.start() 方法報錯,debug ,找出更深層的報錯 在 DocumentationPluginsManager.documentationPlugins()

最後發現是有兩個 Swagger 文件的配置類,然後去掉其中一個就恢復正常了