pom.xml
1 | <dependency> |
```bash
@Configuration
@EnableSwagger2
public class Swagger2 {
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("springboot利用swagger构建api文档")
.description("简单优雅的restfun风格")
.termsOfServiceUrl("http://www.zimug.com")
.version("1.0")
.build();
}
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
//扫描basePackage包下面的“/rest/”路径下的内容作为接口文档构建的目标
.apis(RequestHandlerSelectors.basePackage("com.zimug.bootlaunch"))
.paths(PathSelectors.regex("/rest/.*"))
.build();
}
}1