1.组件版本
springboot 2.4.10
swagger
<dependency>
<groupId>com.spring4all</groupId>
<artifactId>swagger-spring-boot-starter</artifactId>
<version>2.0.</version>
</dependency>
问题报错
Error starting ApplicationContext. To display the conditions report re-run your application with ‘debug’ enabled.
21-10-13 09:35:07,495 ERROR SpringApplication:860 - Application run failed
: Error creating bean with name ‘apiDocumentationScanner’ defined in URL [jar:file:/D:/wukongjiance/wuk-base3.0/wuk-system/target/wuk-system-3.0.0-RELEASE/WEB-INF/lib/springfox-spring-web-3.0.!/springfox/documentation/spring/web/scanners/]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is : Error creating bean with name ‘apiListingScanner’ defined in URL [jar:file:/D:/wukongjiance/wuk-base3.0/wuk-system/target/wuk-system-3.0.0-RELEASE/WEB-INF/lib/springfox-spring-web-3.0.!/springfox/documentation/spring/web/scanners/]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is : Error creating bean with name ‘apiDescriptionReader’ defined in URL [jar:file:/D:/wukongjiance/wuk-base3.0/wuk-system/target/wuk-system-3.0.0-RELEASE/WEB-INF/lib/springfox-spring-web-3.0.!/springfox/documentation/spring/web/scanners/]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is : Error creating bean with name ‘cachingOperationReader’ defined in URL [jar:file:/D:/wukongjiance/wuk-base3.0/wuk-system/target/wuk-system-3.0.0-RELEASE/WEB-INF/lib/springfox-spring-web-3.0.!/springfox/documentation/spring/web/scanners/]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is : Error creating bean with name ‘apiOperationReader’ defined in URL [jar:file:/D:/wukongjiance/wuk-base3.0/wuk-system/target/wuk-system-3.0.0-RELEASE/WEB-INF/lib/springfox-spring-web-3.0.!/springfox/documentation/spring/web/readers/operation/]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is : Error creating bean with name ‘documentationPluginsManager’: Unsatisfied dependency expressed through field ‘documentationPlugins’; nested exception is : Error creating bean with name ‘createSpringFoxRestApi’ defined in class path resource [com/spring4all/swagger/]: Bean instantiation via factory method failed; nested exception is : Failed to instantiate [void]: Factory method ‘createSpringFoxRestApi’ threw exception; nested exception is
问题原因
在使用swagger的时候未正确配置配置文件,导致启动失败
swagger会从SwaggerProperties这个类中加载globalOperationParameters我刚好没有配置这个swagger的配置文件,这才导致了启动失败
参考文章
/SpringForAll/spring-boot-starter-swagger