在SpringBoot中集成Swagger文档,可以通过以下步骤:
在SpringBoot中集成Swagger文档,可以通过以下步骤:
- 添加Swagger依赖: 在项目的pom.xml文件中添加Swagger的依赖:
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>
@Configuration
@EnableSwagger2
publicclassSwaggerConfig{
@Bean
publicDocketapi(){
returnnewDocket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage("com.example.controller"))
.paths(PathSelectors.any())
.build();
}
}
通过以上步骤,就可以在SpringBoot应用中集成Swagger文档。Swagger可以帮助开发人员更方便地查看和测试API接口。
版权声明
本文仅代表作者观点,不代表博信信息网立场。