如何在SpringBoot里使用SwaggerUI

2025-04-02 12:20:56
推荐回答(1个)
回答(1):

SpringBoot嵌入SwaggerUI
步骤
1.jar包引入

io.springfox
springfox-swagger-ui
2.2.2
compile


io.springfox
springfox-swagger2
2.2.2
compile

2.基于SpringBoot配置SwaggerConfig
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket newsApi() {
//return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select().paths(PathSelectors.any()).build();
Docket docket = new Docket(DocumentationType.SWAGGER_2);
docket.enable(true);
docket.apiInfo(apiInfo()).select().paths(PathSelectors.any()).build();
return docket;
}