springboot整合swagger2

启动类 

        @EnableSwagger2

Swagger2 配置类

package com.sie.saaf.app.filter;

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;

@Configuration

public class Swagger2 {

@Bean

  public DocketcreateRestApi() {

return new Docket(DocumentationType.SWAGGER_2)

.apiInfo(apiInfo())

.select()

.apis(RequestHandlerSelectors.basePackage("com.sie.saaf.activity"))

.paths(PathSelectors.any())

.build();

  }

private ApiInfoapiInfo() {

return new ApiInfoBuilder()

.title("SAAF5.0 APP 接口")

.description("APP 接口")

.termsOfServiceUrl("http://blog.etjava.com/")

.version("1.0")

.build();

  }

}


pom.xml

            io.springfox

            springfox-swagger2

            2.6.1

       

       

            io.springfox

            springfox-swagger-ui

            2.6.1

       

你可能感兴趣的:(springboot整合swagger2)