日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > javascript >内容正文

javascript

Spring Boot整合swagger2(生成有左右菜单式的api文档界面)

發布時間:2024/9/27 javascript 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Spring Boot整合swagger2(生成有左右菜单式的api文档界面) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

一、pom.xml內容:

<!--=====依賴swagger2 zhongzk 2019.7.7 --> <dependency><groupId>io.springfox</groupId><artifactId>springfox-swagger2</artifactId><version>2.9.2</version> </dependency> <dependency><groupId>com.github.ohcomeyes</groupId><artifactId>swagger-ui-layer</artifactId><version>1.2</version> </dependency>

二、SwaggerConfig.java

package com.zjm.gwork.utils;import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.context.request.async.DeferredResult; import springfox.documentation.service.ApiInfo; import springfox.documentation.spi.DocumentationType; import springfox.documentation.spring.web.plugins.Docket; import springfox.documentation.swagger2.annotations.EnableSwagger2;/*** @ClassName: SwaggerConfig* @Description: SwaggerConfig 配置類* 1.* 2.* @Author: zhongzk 28582157@qq.com* @Date: 2019/7/7 13:33 ** @Copyright: 2018 字節碼團隊www.bjsurong.com. All rights reserved. **/ @Configuration @EnableSwagger2 public class SwaggerConfig {@Beanpublic Docket ProductApi() {return new Docket(DocumentationType.SWAGGER_2).genericModelSubstitutes(DeferredResult.class).useDefaultResponseMessages(false).forCodeGeneration(false).pathMapping("/").select().build().apiInfo(productApiInfo());}private ApiInfo productApiInfo() {ApiInfo apiInfo = new ApiInfo("GWORK系統數據接口文檔","文檔描述。。。","1.0.0","API TERMS URL","聯系人郵箱:18618281321@163.com","license","license url");return apiInfo;} }

三、訪問:swagger-ui-layer 的默認訪問地址是 http://host:{host}:host:{port}/api-docs.html

例如: http://localhost:7001/api-docs.html

四、說明:

為了生成漂亮的api文檔,有沒有采用swagger2本身的生成文檔ui,而是參考了實現左右菜單式:

效果圖:

1.https://github.com/caspar-chen/swagger-ui-layer

2.https://github.com/ohcomeyes/swagger-ui-layer (最終用了這個,它在上面一個進行的界面修改定制)

總結

以上是生活随笔為你收集整理的Spring Boot整合swagger2(生成有左右菜单式的api文档界面)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。