springboot整合swagger3.0配置集UI界面优化
作者:互联网
- 添加pom依赖
//swagger 界面优化依赖
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
<version>3.0.3</version>
</dependency>
//swagger3.0依赖
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>
- 添加配置类
package com.macro.mall.tiny.config;
import io.swagger.annotations.ApiOperation;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.oas.annotations.EnableOpenApi;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
/**
* @author 崔令雨
* @date 2022/5/18 17:17
* @Version 1.0
*/
@Configuration
@EnableOpenApi
public class SwaggerConfig {
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.OAS_30)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.basePackage("com.macro.mall.tiny.controller"))
.paths(PathSelectors.any())
.build();
}
@Bean
public ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("接口文档")
.description("更多信息请咨询开发者mall")
.contact(new Contact("cui", "https://user.qzone.qq.com/575233534/infocenter", "575233534@qq.com"))
.version("1.0")
.build();
}
}
- 访问http://ip:port/doc.html
标签:documentation,springboot,swagger3.0,UI,new,import,springfox,com,public 来源: https://www.cnblogs.com/cuiwnd/p/16286704.html