午夜剧场伦理_日本一道高清_国产又黄又硬_91黄色网战_女同久久另类69精品国产_妹妹的朋友在线

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

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

瀏覽:102日期: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//是否開(kāi)啟swagger@ConditionalOnProperty(name = 'swagger.enable', havingValue = 'true')public class Swagger2 {// swagger2的配置文件,這里可以配置swagger2的一些基本的內(nèi)容,比如掃描的包等等@Beanpublic Docket createRestApi() {return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select()// 為當(dāng)前包路徑.apis(RequestHandlerSelectors.basePackage('com.oauth.controller')).paths(PathSelectors.any()).build();}private ApiInfo apiInfo() {return new ApiInfoBuilder()// 頁(yè)面標(biāo)題.title('Swagger2')// 創(chuàng)建人信息.contact(new Contact('scy', '666', '888'))// 版本號(hào).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 這里是設(shè)置是否啟動(dòng) 本地和測(cè)試環(huán)境為true 正式環(huán)境為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 = '測(cè)試接口', 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';}}

打開(kāi)swagger頁(yè)面 localhost:端口號(hào)/swagger-ui.html

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

如果swagger:enable: false 這里設(shè)置為false

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

總結(jié)

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

標(biāo)簽: Spring
相關(guān)文章:
主站蜘蛛池模板: 精品香蕉一区二区三区 | 成年人在线观看视频网站 | 日韩欧美在线看 | 樱桃视频污在线观看 | 亚洲成人免费 | www.国产成人| 狠狠插狠狠插 | 国产在线网址 | 色视频免费观看 | 97免费公开视频 | 亚洲在线 | 国产成人一级片 | 久久久久久久久网站 | 国产欲妇 | 九色影院 | 日本色视频 | a在线免费 | 亚洲精品国产精品国自产 | 成年人免费视频播放 | 成人在线免费网站 | 欧美一级全黄 | 亚洲精品国产一区二区 | 国产第六页 | 99精品国产一区二区 | 日韩亚洲欧美在线观看 | www.com日本| 日韩一级片免费看 | 亚洲精品网站在线观看 | 亚洲天堂网在线观看 | 免费看的毛片 | 激情久久视频 | 国产福利精品视频 | 久久av热| 欧美久久影院 | 激情五月激情综合 | 红桃视频国产精品 | 国产精品国产一区二区三区四区 | 久久免费在线观看视频 | 欧美成人一区二区 | 国产激情在线视频 | 五月婷婷视频在线观看 |