Spring Boot 整合 Swagger2 纠错

 这是我出现的错误:

***************************
APPLICATION FAILED TO START
***************************

Description:

Parameter 0 of constructor in springfox.documentation.swagger.schema.ApiModelPropertyPropertyBuilder required a bean of type 'springfox.documentation.spring.web.DescriptionResolver' that could not be found.


Action:

Consider defining a bean of type 'springfox.documentation.spring.web.DescriptionResolver' in your configuration.

这是项目导入的依赖关系:

<dependency>
     <groupId>io.springfox</groupId>
     <artifactId>springfox-swagger2</artifactId>
     <version>2.9.2</version>
 </dependency>
 <!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui -->
 <dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger-ui</artifactId>
    <version>2.9.2</version>
 </dependency>

        因为我要建立的是微服务的项目,需要建立许多模块,以至于我在父工程中引入了当前模块,然后我在子模块中又引入了当前模块,造成了冲突。

        另外一种解决方法是,经过上网查证,可能由于Spring Boot和Swagger版本的问题,Spring Boot2.6以上的版本,需要使用到Swagger的版本是2.9.7,而且引入的两个版本要是相同的。

        如果您感觉对您有帮助,欢迎关注我一下,谢谢。

猜你喜欢

转载自blog.csdn.net/m0_57037182/article/details/127440180