springBoot 配置SwaggerUi接口测试

1. 通过maven导入jar包

复制代码
<!-- 引入swagger相关的jar -->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.9.2</version>
        </dependency>

        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.9.2</version>
        </dependency>
复制代码

2. 编写SwaggerConfig配置文件

复制代码
@Configuration
@EnableSwagger2
public class SwaggerConfig {
    @Bean
    public Docket createRestApi(){
        return new Docket(DocumentationType.SWAGGER_2)
                .pathMapping("/")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.tw.skynet.controller"))   //项目接口类路径
                .paths(PathSelectors.any())
                .build().apiInfo(new ApiInfoBuilder()
                        .title("API接口调试")
                        .description("详细信息")
                        .version("1.0")
                        .contact(new Contact(
                                "drgs",  //项目名称
                                "https://www.00.cn",  //备注网址
                                "11111111111@163.com"))  //备注邮箱地址
                        .license("The Apache License")
                        .licenseUrl("https://www.00.cn")
                        .build()
                );
    }
}
复制代码

 

posted @   _情书  阅读(142)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
· SQL Server 2025 AI相关能力初探
· 为什么 退出登录 或 修改密码 无法使 token 失效
点击右上角即可分享
微信分享提示