标签:inf package expected mon 地址 import nta nbsp 用户
Swagger官网:http://swagger.io
GitHub地址:https://github.com/swagger-api
官方注解文档:http://docs.swagger.io/swagger-core/apidocs/index.html
Swagger-UI地址:https://github.com/swagger-api/swagger-ui

<!-- 构建Restful API 我这版本是2.6.1 -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${swagger2.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${swagger2.version}</version>
</dependency>
<!-- url是你需要扫描swagger的包路径 --> <context:component-scan base-package="com.nickwilde.microtrain.common.config.swagger"/>
package com.nickwilde.microtrain.common.config.swagger2;
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;
/**
* @author NickWilde
* @version 2018/1/18 10:23
* @description: Swagger2Config
* TODO 用一句话描述
*/
@Configuration
@EnableSwagger2
public class Swagger2Config{
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2).forCodeGeneration(true)
.select()
.apis(RequestHandlerSelectors.any())
//过滤生成链接
.paths(PathSelectors.any())
.build()
.apiInfo(apiInfo());
}
//api接口作者相关信息
private ApiInfo apiInfo() {
Contact contact = new Contact("NickWilde", "", "1064698801@qq.com");
ApiInfo apiInfo = new ApiInfoBuilder()
.license("Apache License Version 2.0")
.title("Unexpectedly系统")
.description("接口文档")
.contact(contact)
.version("1.0")
.build();
return apiInfo;
}
}
@ApiOperation(value="根据User对象创建用户", notes="根据User对象创建用户",httpMethod = "POST") //httpMehtod如果不定义,那么swagger会有把该接口的所有请求方法都一一列举出来 @ApiImplicitParam(name = "data", value = "data描述", required = true, dataType = "UserInfo") //参数定义..类型..之类的,这是基础简单,其余的看api吧~
标签:inf package expected mon 地址 import nta nbsp 用户
原文地址:https://www.cnblogs.com/weixupeng/p/11395896.html