: Failed to start bean ‘documentationPluginsB

时间:2025-03-21 10:25:28

一、错误详细信息:

: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is 
	at (:181) ~[spring-context-5.3.:5.3.15]
	at $200(:54) ~[spring-context-5.3.:5.3.15]
	at $(:356) ~[spring-context-5.3.:5.3.15]
	at (:75) ~[na:1.8.0_261]
	at (:155) ~[spring-context-5.3.:5.3.15]
	at (:123) ~[spring-context-5.3.:5.3.15]
	at (:935) ~[spring-context-5.3.:5.3.15]
	at (:586) ~[spring-context-5.3.:5.3.15]
	at (:145) ~[spring-boot-2.6.:2.6.3]
	at (:732) [spring-boot-2.6.:2.6.3]
	at (:414) [spring-boot-2.6.:2.6.3]
	at (:302) [spring-boot-2.6.:2.6.3]
	at (:1303) [spring-boot-2.6.:2.6.3]
	at (:1292) [spring-boot-2.6.:2.6.3]
	at (:11) [classes/:na]
	at .invoke0(Native Method) ~[na:1.8.0_261]
	at (:62) ~[na:1.8.0_261]
	at (:43) ~[na:1.8.0_261]
	at (:498) ~[na:1.8.0_261]
	at (:49) [spring-boot-devtools-2.6.:2.6.3]
Caused by: : null
	at (:56) ~[springfox-spring-webmvc-3.0.:3.0.0]
	at (:113) ~[springfox-core-3.0.:3.0.0]
	at $byPatternsCondition$3(:89) ~[springfox-spi-3.0.:3.0.0]
	at $comparing$77a9974f$1(:469) ~[na:1.8.0_261]
	at (:355) ~[na:1.8.0_261]
	at (:220) ~[na:1.8.0_261]
	at (:1512) ~[na:1.8.0_261]
	at (:1464) ~[na:1.8.0_261]
	at $(:387) ~[na:1.8.0_261]
	at $(:258) ~[na:1.8.0_261]
	at $(:258) ~[na:1.8.0_261]
	at $(:258) ~[na:1.8.0_261]
	at $(:258) ~[na:1.8.0_261]
	at (:483) ~[na:1.8.0_261]
	at (:472) ~[na:1.8.0_261]
	at $(:708) ~[na:1.8.0_261]
	at (:234) ~[na:1.8.0_261]
	at (:499) ~[na:1.8.0_261]
	at (:81) ~[springfox-spring-webmvc-3.0.:3.0.0]
	at $3$(:193) ~[na:1.8.0_261]
	at $(:1384) ~[na:1.8.0_261]
	at (:482) ~[na:1.8.0_261]
	at (:472) ~[na:1.8.0_261]
	at $(:708) ~[na:1.8.0_261]
	at (:234) ~[na:1.8.0_261]
	at (:499) ~[na:1.8.0_261]
	at (:107) ~[springfox-spring-web-3.0.:3.0.0]
	at (:91) ~[springfox-spring-web-3.0.:3.0.0]
	at (:82) ~[springfox-spring-web-3.0.:3.0.0]
	at (:100) ~[springfox-spring-web-3.0.:3.0.0]
	at (:178) ~[spring-context-5.3.:5.3.15]
	... 19 common frames omitted

Disconnected from the target VM, address: '127.0.0.1:1120', transport: 'socket'

Process finished with exit code 1

二、报错原因(提示初始化文档插件的Bean失败--Failed to start bean 'documentationPluginsB),上网查了一下原来是我用的 SpringBoot2.与Swagger2 3.0.0版本冲突了。

三、解决办法

方法1. 在服务的配置中添加如下配置:

# 处理SpringBoot2.与Swagger2 3.0.0版本冲突
-strategy=ant_path_matcher

方法2.  降低Swagger2版本,因为我不想为了Swagger2降低我的Springboot版本(然而并没有什么卵用,依旧报错):

<!--swagger-->
<dependency>
    <groupId></groupId>
    <artifactId>springfox-swagger2</artifactId>
    <version>2.9.2</version>
</dependency>
<!--swagger ui-->
<dependency>
    <groupId></groupId>
    <artifactId>springfox-swagger-ui</artifactId>
    <version>2.9.2</version>
</dependency>

方法3.  将SpringBoot版本降低到2.6以下