spring boot 集成swagger2
1 在pom.xml
中加入Swagger2的依赖
<dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.8.0</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>2.8.0</version> </dependency>
2
@Configuration @EnableSwagger2 public class SwaggerConfig { @Bean public Docket createRestApi() { return new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()) .select() .apis(RequestHandlerSelectors.basePackage("tech.duor.sunflower"))//扫描包 .paths(PathSelectors.any()) .build(); } private ApiInfo apiInfo() { return new ApiInfoBuilder() .title("标题") .description("描述") .termsOfServiceUrl("http://duor.tech/") .contact("创建人") .version("0.1") .build(); } }
3 . controller
@Api(description = "xxController", value = "描述") @CrossOrigin @RestController @RequestMapping("/api/system") //@Scope("prototype") public class PalletController { @ApiOperation(value = "查询全部的货盘分页展示", notes = "") @ApiImplicitParam(name = "Authorization", paramType = "header") @RequestMapping(value = "/pallet", method = RequestMethod.GET) public RestResult QueryPallets(){} }
https://www.jianshu.com/p/8033ef83a8ed
https://www.imooc.com/article/20521
在浏览器中输入你配置的网址就可以访问
http://localhost:8011/index.html
https://www.jianshu.com/p/528b2db2ab7f
下载 dist 放到
修改 index.html