Springboot集成Swagger
创建Springboot_swagger项目
-
pom.xml
<dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>2.9.2</version> </dependency> <!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 --> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.9.2</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency>
配置swagger
@Configuration
@EnableSwagger2//开启swagger2
public class SwaggerConfig {
}
- 测试运行,访问
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存失败,源站可能有防盗链机制,建议将图片保存下来直接上传下上传(icoP7y1jyeqU-1581737067488)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20200215094641521.png)(
C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20200215094641521.png)]
配置swagger信息
swagger的bean实例Docket;
@Configuration
@EnableSwagger2//开启swagger2
public class