【问题标题】:AWS V1 ClientConfiguration to V2 ClientOverrideConfigurationAWS V1 ClientConfiguration 到 V2 ClientOverrideConfiguration
【发布时间】:2022-07-22 06:04:59
【问题描述】:

我正在将一堆代码从 AWS V1 sdk 重构到 V2,并且一直在为 GlueClient 创建代理配置。

V1 代码:

ClientConfiguration clientConfiguration = new ClientConfiguration();
clientConfiguration.setProxyPort(8443);
clientConfiguration.setProtocol(Protocol.HTTPS);

V2 代码:

ClientOverrideConfiguration.builder(). ??? .build();

我找不到任何很好的例子来说明如何做到这一点。 V2 的替换类中似乎没有任何代理选项

【问题讨论】:

    标签: amazon-web-services sdk aws-glue


    【解决方案1】:

    我将假设您使用基于类名的 Java SDK,在这种情况下,您在 HTTPClientBuilder 上设置代理配置。这是一个使用默认 (Apache) 客户端构建器的示例,取自 this gist,它显示了一个完整的程序并将其与 V1 代理配置进行了比较。

    ProxyConfiguration config = ProxyConfiguration.builder()
                                .endpoint(new URI("http://localhost:3128"))
                                .addNonProxyHost("169.254.169.254")
                                .useSystemPropertyValues(Boolean.FALSE)
                                .build();
    
    ApacheHttpClient.Builder clientBuilder = ApacheHttpClient.builder()
                                             .proxyConfiguration(config);
    
    StsClient client = StsClient.builder()
                       .httpClientBuilder(clientBuilder)
                       .build();
    

    您可能还对通过环境变量或系统属性自动配置代理的方法感兴趣,我已经记录了 here。 TL;DR:这是一团糟。

    【讨论】:

      猜你喜欢
      • 2023-02-16
      • 1970-01-01
      • 2019-07-25
      • 1970-01-01
      • 2022-07-29
      • 2013-12-04
      • 1970-01-01
      • 2016-11-22
      • 1970-01-01
      相关资源
      最近更新 更多