内射老阿姨1区2区3区4区_久久精品人人做人人爽电影蜜月_久久国产精品亚洲77777_99精品又大又爽又粗少妇毛片

Springboot項目接口之swagger怎么用

這篇文章給大家介紹Springboot項目接口之swagger怎么用,內(nèi)容非常詳細,感興趣的小伙伴們可以參考借鑒,希望對大家能有所幫助。

十載的平陽網(wǎng)站建設經(jīng)驗,針對設計、前端、開發(fā)、售后、文案、推廣等六對一服務,響應快,48小時及時工作處理。成都營銷網(wǎng)站建設的優(yōu)勢是能夠根據(jù)用戶設備顯示端的尺寸不同,自動調(diào)整平陽建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設計,從而大程度地提升瀏覽體驗。成都創(chuàng)新互聯(lián)從事“平陽網(wǎng)站設計”,“平陽網(wǎng)站推廣”以來,每個客戶項目都認真落實執(zhí)行。

step1:pom文件引入swagger插件

<!-- swagger -->
<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>
<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-web</artifactId>
</dependency>

step2:添加SwaggerConfig.java

package com.ggkt.crm.admin.config;

import org.springframework.beans.factory.annotation.Value;
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.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * Title: Swagger
 * Description:接口測試(可用、可不用)
 * @author ggkt
 *
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {

	@Value(value = "${swagger.enabled}")
	private Boolean swaggerEnabled;
	 
	@Bean
    public Docket createAllotManageApi() {
        return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo())
                .groupName("分配管理")
                // 是否開啟
                .enable(swaggerEnabled).select()
                // 掃描的路徑包
                .apis(RequestHandlerSelectors.basePackage("com.ggkt.crm.admin.allotManage.dataType.controller"))
                // 指定路徑處理PathSelectors.any()代表所有的路徑
                .paths(PathSelectors.any()).build().pathMapping("/");
    }
	
	@Bean
    public Docket createMarketManageApi() {
        return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo())
                .groupName("營銷管理")
                // 是否開啟
                .enable(swaggerEnabled).select()
                // 掃描的路徑包
                .apis(RequestHandlerSelectors.basePackage("com.ggkt.crm.admin.marketManage"))
                // 指定路徑處理PathSelectors.any()代表所有的路徑
                .paths(PathSelectors.any()).build().pathMapping("/");
    }

    @Bean
    public Docket createBaseManageApi() {
        return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo())
                .groupName("基礎配置管理")
                // 是否開啟
                .enable(swaggerEnabled).select()
                // 掃描的路徑包
                .apis(RequestHandlerSelectors.basePackage("com.ggkt.crm.admin.baseManage"))
                // 指定路徑處理PathSelectors.any()代表所有的路徑
                .paths(PathSelectors.any()).build().pathMapping("/");
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("接口文檔")
                .description("API")
                .version("1.0.0")
                .build();
    }
}

step3:domain類注釋方式
Springboot項目接口之swagger怎么用

step4:Controller類的注釋方式
Springboot項目接口之swagger怎么用

step5:application.yml配置
Springboot項目接口之swagger怎么用

6、接口訪問
http://localhost:9099/admin/swagger-ui.html
Springboot項目接口之swagger怎么用

關于Springboot項目接口之swagger怎么用就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,可以學到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。

新聞標題:Springboot項目接口之swagger怎么用
分享地址:http://www.rwnh.cn/article40/jsdcho.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供域名注冊、建站公司、企業(yè)建站、企業(yè)網(wǎng)站制作商城網(wǎng)站、網(wǎng)站導航

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)站建設
房山区| 文登市| 神农架林区| 安仁县| 东明县| 旺苍县| 浑源县| 天峨县| 孟州市| 沭阳县| 两当县| 大同县| 宁晋县| 江油市| 齐齐哈尔市| 文山县| 五华县| 南宫市| 龙山县| 沭阳县| 始兴县| 汽车| 莲花县| 开封市| 横峰县| 莒南县| 民乐县| 大庆市| 育儿| 南宫市| 饶阳县| 台中市| 扎兰屯市| 林西县| 蒙山县| 寻甸| 宣汉县| 温州市| 毕节市| 元阳县| 安西县|