- jar
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
- bean配置类
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.pathMapping("/")
.select()
.apis(RequestHandlerSelectors.basePackage("com.andy.controller"))
.paths(PathSelectors.any())
.build().apiInfo(new ApiInfoBuilder()
.title("xx公司API文档")
.description("xx公司API文档")
.version("9.0")
.contact(new Contact("Andy", "blog.csdn.net", "xxx@126.com"))
.license("The Apache License")
.licenseUrl("http://www.baidu.com")
.build());
}
}
访问 http://localhost:8080/swagger-ui.html
当然可以结合swagger 注解配置在controller上
@Api ,@ApiOperation,@ApiImplicitParams