Live2D

swagger的简单使用

1.引入依赖
   <!--SwaggerUI-->
    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger-ui</artifactId>
        <version>2.9.2</version>
    </dependency>
    <!--Swagger2-->
    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger2</artifactId>
        <version>2.9.2</version>
    </dependency>
2.配置swagger以及信息
@Configuration
@EnableSwagger2 //开启Swagger
public class SwaggerConfig {
// 配置首页信息
@Bean
public Docket docket(){

    //RequestHandlerSelectors.basePackage("com.wl.controller")  扫描指定的包
    // paths()  需要过滤的路径
    // enable配置是否启动 默认为true
    return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo())
            .enable(true)
            .select()
            .apis(RequestHandlerSelectors.basePackage("com.wl.controller"))
//                .paths(PathSelectors.ant(""))
            .build();
}
private ApiInfo apiInfo(){
    // 作者姓名 项目路径
    Contact DEFAULT_CONTACT = new Contact("wl", "", "2315290571@qq.com");
    return new ApiInfo("wl测试的api文档",
            "即使再小的帆也能远航",
            "1.0",
            "http://localhost:8080/hello",
            DEFAULT_CONTACT,
            "Apache 2.0",
            "http://www.apache.org/licenses/LICENSE-2.0",
            new ArrayList()
    );
}
}
posted @   没有梦想的java菜鸟  阅读(87)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
阅读排行:
· winform 绘制太阳,地球,月球 运作规律
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
点击右上角即可分享
微信分享提示