springBoot配置Swagger
阿新 • • 發佈:2018-11-11
1.在pom.xml
中加入Swagger2的依賴
<dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>${swagger.version}</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>${swagger.version}</version> </dependency>
2.建立Swagger2配置類
@Configuration @EnableSwagger2 public class Swagger2 { @Bean public Docket createResApi() { return new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()) .select() .apis(RequestHandlerSelectors.basePackage("blog.manager.web.bff")) .paths(PathSelectors.any()) .build(); } private ApiInfo apiInfo() { return new ApiInfoBuilder() .title("部落格管理系統") .description("RESTful API") .termsOfServiceUrl("") .version("1.0") .build(); } } 如圖:
3.執行效果圖