转自:/entry/355158
首先,引入maven依赖
<dependency>
<groupId></groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<groupId></groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.7.0</version>
</dependency>
Swagger2是一个效率工具
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ..EnableSwagger2;
/**
* Created by Trace on 2018-05-16.<br/>
* Desc: swagger2配置类
*/
@SuppressWarnings({"unused"})
@Configuration @EnableSwagger2
public class Swagger2Config {
@Value("${}") private boolean enable;
@Bean("用户模块")
public Docket userApis() {
return new Docket(DocumentationType.SWAGGER_2)
.groupName("用户模块")
.select()
.apis(())
.paths(("/user.*"))
.build()
.apiInfo(apiInfo())
.enable(enable);
}
@Bean("客户模块")
public Docket customApis() {
return new Docket(DocumentationType.SWAGGER_2)
.groupName("客户模块")
.select()
.apis(())
.paths(("/custom.*"))
.build()
.apiInfo(apiInfo())
.enable(enable);
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("XXXXX系统平台接口文档")
.description("提供子模块1/子模块2/子模块3的文档, 更多请关注公众号: 随行享阅")
.termsOfServiceUrl("//")
.version("1.0")
.build();
}
}
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ..EnableSwagger2;
/**
* Swagger2 配置
* Created by pmdream on 2018/4/20.
*/
@Configuration
@EnableSwagger2
public class Swagger2 {
@Value("${}")
private boolean swaggerShow;
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.enable(swaggerShow)
.apiInfo(apiInfo())
.select()
.apis((""))
.paths(())
.build();
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("接口文档")
.description("测试Swagger")
.termsOfServiceUrl("/")
.contact("pmdream")
.version("1.0")
.build();
}
}
= =(留着之后填坑)