springboot整合swagger3

首先引入依赖

  <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-boot-starter</artifactId>
            <version>3.0.0</version>
        </dependency>

创建配置类:Swagger3Confing,注意事项:需要添加@EnableOpenApi、@EnableWebMvc这两个注解否则无法启动,

apiInfo()方法里面的内容需要查看ApiInfo类里面的信息进行添加 

复制代码
 @Bean
    public Docket docket(){
        return new Docket(DocumentationType.OAS_30)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.boot.controller"))
                .paths(PathSelectors.any())
                .build();
    }


    @SuppressWarnings("all")
    public ApiInfo apiInfo(){
        return new ApiInfo(
                "xxx api",
                "redis project",
                "v1.0",
                "xxxxxxx", 
                "xxxx",
                "Apache 2.0",  //许可证
                "http://www.apache.org/licenses/LICENSE-2.0" //许可证链接
        );
    }
复制代码

注意事项:引入swagger以后spring boot不能访问templates文件夹的index.html文件

posted @   敲代码的空白格  阅读(418)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
点击右上角即可分享
微信分享提示