Swagger3在Swagger2的基础上进行了部分升级, 使用和Swagger2没有多少区别。
一个重要的优化是依赖的引入,由之前的多个依赖变更为一个依赖,跟随springboot-starter风格,同时引入了新的开关注解 @EnableOpenApi 以代替@EnableSwagger2 。
一、Maven依赖
<!-- 引入swagger3包 -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>
二、application.yml文件配置
spring:
mvc:
pathmatch:
matching-strategy: ant_path_matcher
三、添加配置Swagger
(必选)添加开关注解@EnableOpenApi
package com.dong.springxiaobai.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springf