SpringBoot2.7集成Swagger3
1、引入pom坐标
<!--swagger--> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>3.0.0</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-boot-starter</artifactId> <version>3.0.0</version> </dependency>
2、配置类
@Configuration public class SwaggerConfig { @Bean public Docket docket() { return new Docket(DocumentationType.OAS_30) .apiInfo(apiInfo()) .select() .apis(RequestHandlerSelectors.any()) .paths(PathSelectors.any()) .build(); } private ApiInfo apiInfo() { return new ApiInfoBuilder().build(); } }
3、application.yml配置
spring:
mvc:
pathmatch:
matching-strategy: ant_path_matcher
4、重启项目访问swagger页面
http://127.0.0.1:8090/swagger-ui/index.html