Spring swagger2:如何设置 HTTPS 协议?

时间:2021-05-17 15:05:32

标签: java spring mongodb swagger

当我在 swagger 中执行我的 spring 应用程序时,默认协议是 http,我想在 https 中执行它,因为应用程序在 HTTPS 中运行。我该如何配置?

这是我的代码:

@Configuration
@EnableSwagger2
public class SwaggerConfig{
    @Bean
    public Docket api() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(metaData())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.adp.mnc.metadata.controller"))
                .paths(PathSelectors.any())
                .build();

    }

1 个答案:

答案 0 :(得分:0)

您可以使用.protocols(Sets.newHashSet("http", "https"))