<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>
在使用Swagger2引入以下依赖后报错如图
总体上看似乎没有问题,但是启动的时候,报了以下的错误,因为这个错误,找了许久也浪费了好多时间,最后发现是springboot与swagger发生版本不兼容的问题。主要有两个解决的方案。
方案一:在xxx.yml文件中
加上:
spring:
mvc:
pathmatch:
matching-strategy: ant_path_matcher
如果是xxx.properties文件中加上:
spring: mvc: pathmatch: matching-strategy: ANT_PATH_MATCHER
方案二:springboot降级
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.7</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
原文链接:https://blog.csdn.net/weixin_60785926/article/details/123958439