springfox-swagger版本导致的springboot jar方式启动异常

系统以jar方式运行时,报如下错误,导致启动失败

2022-07-22 11:11:14.253 WARN 16024 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'apiModelPropertyPropertyBuilder' defined in URL [jar:file:/E:/asset-manage/3source/platform-asset/target/platform-asset-4.0.0-SNAPSHOT.jar!/BOOT-INF/lib/springfox-swagger-common-2.9.2.jar!/springfox/documentation/swagger/schema/ApiModelPropertyPropertyBuilder.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'springfox.documentation.spring.web.DescriptionResolver' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}

2022-07-22 11:11:20.296 ERROR 16024 --- [g.push.receiver] com.alibaba.nacos.client.naming : [NA] error while receiving push data

java.net.SocketException: socket closed

经排查,与springfox-swagger版本有关

knife4j 2.0.6以上的版本,要求springboot的版本要高于2.2.x,而现在工程的springboot是2.1.18,因为knife4j 2.0.6以上版本底层依赖的springfox-swagger是2.10,2.0.6以下用的是2.9,springfox-swagger2.10和2.9的一个区别是不再使用@EnableSwagger2,改为@EnableSwagger2WebMvc,对spring-plugin-core也有依赖

目前最简单的解决办法,knife4j从2.0.9,降到2.0.5


版权声明:本文为lzfxpuugv原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。