Swagger3.0访问网址

在这里插入图片描述

今天看了学习视频,老师用的swagger是2.0+版本的,我找到了最新的3.0版本,但是写完swagger配置类之后,发现swagger-ui.html网址进不了,才发现是3.0修改了访问地址为:swagger-ui/index.html.
我的依赖为:

<dependency>
			<groupId>io.springfox</groupId>
			<artifactId>springfox-boot-starter</artifactId>
			<version>3.0.0</version>
		</dependency>

配置类:

package com.kuang.swagger.config;

import org.springframework.context.annotation.Configuration;
import springfox.documentation.oas.annotations.EnableOpenApi;


@Configuration
@EnableOpenApi  //开启Swagger
public class SwaggerConfig {


}

3.0swagger相关错误:
1.

Failed to start bean ‘documentationPluginsBootstrapper’; nested exception is java.lang.NullPointerException

原因: 这是因为Springfox使用的路径匹配是基于AntPathMatcher的,而Spring Boot 2.6.X使用的是PathPatternMatcher。
解决: 修改application.yaml spring: mvc: pathmatch: matching-strategy: ANT_PATH_MATCHER
转自一位帖子的评论区大佬,路径:解决办法–>见评论区
2.swagger3访问地址

猜你喜欢

转载自blog.csdn.net/CSDN13822805069/article/details/122980825