springboot利用swagger实现配置yml文件-创新互联

今天就跟大家聊聊有关spring boot利用swagger实现配置yml文件,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。

双鸭山网站建设公司创新互联,双鸭山网站设计制作,有大型网站制作公司丰富经验。已为双鸭山近千家提供企业网站建设服务。企业网站搭建\外贸网站建设要多少钱,请找那个售后服务好的双鸭山做网站的公司定做!

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的一些基本的内容,比如扫描的包等等
	@Bean
	public 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();
	}
}

网页题目:springboot利用swagger实现配置yml文件-创新互联
网页地址:http://lszwz.com/article/dsiegg.html

其他资讯

售后响应及时

7×24小时客服热线

数据备份

更安全、更高效、更稳定

价格公道精准

项目经理精准报价不弄虚作假

合作无风险

重合同讲信誉,无效全额退款