成人视屏在线观看-国产99精品-国产精品1区2区-欧美一级在线观看-国产一区二区日韩-色九九九

您的位置:首頁技術文章
文章詳情頁

spring boot-2.1.16整合swagger-2.9.2 含yml配置文件的代碼詳解

瀏覽:40日期:2023-08-22 18:00:26

java代碼

package com.oauth.util;import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;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.service.Contact;import springfox.documentation.spi.DocumentationType;import springfox.documentation.spring.web.plugins.Docket;import springfox.documentation.swagger2.annotations.EnableSwagger2;@Configuration@EnableSwagger2//是否開啟swagger@ConditionalOnProperty(name = 'swagger.enable', havingValue = 'true')public class Swagger2 {// swagger2的配置文件,這里可以配置swagger2的一些基本的內容,比如掃描的包等等@Beanpublic Docket createRestApi() {return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select()// 為當前包路徑.apis(RequestHandlerSelectors.basePackage('com.oauth.controller')).paths(PathSelectors.any()).build();}private ApiInfo apiInfo() {return new ApiInfoBuilder()// 頁面標題.title('Swagger2')// 創建人信息.contact(new Contact('scy', '666', '888'))// 版本號.version('1.0')// 描述.description('API 描述').build();}}

yml文件

server: port: 8587spring: application: name: auth eureka: instance: prefer-ip-address: true client: service-url: defaultZone: http://localhost:8090/eureka/ swagger: enable: true

swagger:enable: true 這里是設置是否啟動 本地和測試環境為true 正式環境為false

controller

package com.oauth.controller;import org.springframework.web.bind.annotation.GetMapping;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RestController;import io.swagger.annotations.Api;import io.swagger.annotations.ApiOperation;@RestController@RequestMapping('api')@Api(value = '測試接口', tags = 'IndexController')public class IndexController {@ApiOperation(value = 'hello')@GetMapping('hello')public String hello() {return 'Hello World';}@ApiOperation(value = 'hello2')@GetMapping('api/hello')public String apiHello() {return 'Hello World';}}

打開swagger頁面 localhost:端口號/swagger-ui.html

spring boot-2.1.16整合swagger-2.9.2 含yml配置文件的代碼詳解

如果swagger:enable: false 這里設置為false

spring boot-2.1.16整合swagger-2.9.2 含yml配置文件的代碼詳解

總結

到此這篇關于spring boot-2.1.16整合swagger-2.9.2 含yml配置文件的文章就介紹到這了,更多相關spring boot整合swagger內容請搜索好吧啦網以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持好吧啦網!

標簽: Spring
相關文章:
主站蜘蛛池模板: 日韩在线视精品在亚洲 | 在线亚洲综合 | 日本二区免费一片黄2019 | 久久综合久美利坚合众国 | 一区两区三不卡 | 黄色一级毛片网站 | 港台三级在线观看 | 99久久一区二区精品 | 欧美二区在线观看 | 国产99视频精品免费视频免里 | 99国产精品视频久久久久 | 国产精品久久久久久爽爽爽 | 国产精品合集久久久久青苹果 | 五月久久亚洲七七综合中文网 | 色综合久久88色综合天天提莫 | 香港一级特黄高清免费 | 国产精品一在线观看 | 久久黄网站 | 一色屋精品亚洲香蕉网站 | 日韩欧美亚洲视频 | 97婷婷狠狠成人免费视频 | 国内精品久久国产大陆 | 欧美第一页草草影院浮力 | 一区二区三区在线免费看 | 亚洲欧美日韩精品香蕉 | 国产成人精品福利网站在线观看 | 国产主播精品福利19禁vip | 国产精品久久久久久一区二区 | 亚洲在线成人 | 亚洲国产夜色在线观看 | 成人毛片18女人毛片免费 | 久久精品一品道久久精品9 久久精品一区 | 波多野结衣一区二区三区在线观看 | 边接电话边做国语高清对白 | 久久国产精品免费网站 | 精品综合久久久久久蜜月 | 久久99亚洲精品久久频 | 一本色道久久综合亚洲精品 | 欧美人在线一区二区三区 | 高清一级淫片a级中文字幕 高清一区二区 | 久久亚洲精品中文字幕亚瑟 |