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

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

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

瀏覽:48日期: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
相關文章:
主站蜘蛛池模板: 国产后式a一视频 | 免费精品国产 | 久9久9精品视频在线观看 | 欧美日产国产亚洲综合图区一 | 国产成人久久综合热 | 欧美俄罗斯一级毛片 | 久久中文字幕亚洲精品最新 | 日韩欧美国产高清在线观看 | 综合自拍 | 国产成人精品aaaa视频一区 | 久色小说 | 国内精品久久久久久久久久影视 | 日韩在线亚洲 | 曰本人做爰大片免费观看一 | 久久青草热 | 国产精品所毛片视频 | 亚洲欧美综合一区二区三区四区 | 亚洲欧美视频在线 | 老王午夜69精品影院 | 国产精品日韩欧美一区二区三区 | 美国一级毛片不卡无毒 | 免费看成人频视在线视频 | 国产精品亚洲一区在线播放 | 国产精品久久久一区二区三区 | 免费国产99久久久香蕉 | 欧美一级欧美三级在线 | 伊人久久影视 | 精品国产1区 | 看成年女人免费午夜视频 | 欧美一区二区三区免费 | 分享一个无毒不卡免费国产 | 日韩国产片 | 热er99久久6国产精品免费 | 亚洲国产一区二区三区综合片 | 久在线播放| 国产亚洲一区在线 | 中国老太卖淫播放毛片 | 国产日韩欧美 | 久久一级视频 | 久久九九热视频 | 久久99国产精品亚洲 |