1.导入依赖
<!--swagger2--> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>3.0.0</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>3.0.0</version> </dependency> <!--整合Knife4j--> <dependency> <groupId>com.github.xiaoymin</groupId> <artifactId>knife4j-spring-boot-starter</artifactId> <version>3.0.3</version> </dependency>
2.配置swagger
@Configuration @EnableSwagger2WebMvc @EnableKnife4j public class SwaggerConfig { @Bean(value = "MyApi") public Docket MyApi() { return new Docket(DocumentationType.SWAGGER_2) .enable(true) .groupName("1-业务管理api") .apiInfo(apiInfo()) .select() .apis(RequestHandlerSelectors.basePackage("com.example.mybatisplus.controller")) .paths(PathSelectors.any()) .build(); } /** * 文档信息 * * @return */ private ApiInfo apiInfo() { return new ApiInfoBuilder() .title("管理系统接口API") .description("api接口文档") .termsOfServiceUrl("http://localhost:8899/mybatis") 项目的端口号和项目名需要一致 .version("1.0.0") .build(); }
标签:return,整合,io,Swagger2,apiInfo,build,3.0,springfox From: https://www.cnblogs.com/hj98/p/16791708.html