【问题标题】:Spring swagger2: how to set HTTPS protocol?Spring swagger2:如何设置 HTTPS 协议?
【发布时间】:2021-05-17 15:05:32
【问题描述】:

当我在 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();

    }

【问题讨论】:

    标签: java spring mongodb swagger


    【解决方案1】:

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

    【讨论】:

    • 无法解析“ApiSelectorBuilder”中的方法“协议”
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-12-02
    • 2020-04-16
    • 1970-01-01
    • 2017-03-16
    • 1970-01-01
    • 2013-07-12
    • 2012-11-18
    相关资源
    最近更新 更多