swagger引入
在pom或者上级pom中引入相关包
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.5.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.2.2</version>
</dependency>
配置swagger服务器
@Configuration
@EnableSwagger2
public class MonitorConfigSwagger {
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.basePackage("com.hisense.monitor.config.controller"))
.paths(PathSelectors.any())
.build();
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("配置中心监控中的API")
.description("版权所有:海信智能商用")
.termsOfServiceUrl("http://saas.hi.com/")
.contact("SAAS平台组")
.version("1.0")
.build();
}
}
Controller中配置
@ApiOperation(value="获取当前应用的详细配置", notes="获取当前应用的详细配置")
@ApiImplicitParam(name = "params", value = "配置信息", required = true)
@RequestMapping(value = "/gettablecurpros", method = RequestMethod.POST)
public Object getCurMongoTablePro(@RequestParam String params) {
return iConfigService.getCurMongoTablePro(params);
}