当我试图调用DynamoDB AWS服务时,下面会出现以下错误:
Multiple HTTP implementations were found on the classpath. To avoid non-deterministic loading implementations, please explicitly provide an HTTP client via the client builders, set the software.amazon.awssdk.http.service.impl system property with the FQCN of the HTTP service to use as the default, or remove all but one HTTP implementation from the classpath我用的是DynamoDbClient
我的pom.xml:
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>dynamodb</artifactId>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>url-connection-client</artifactId>
</dependency>客户端配置:
@Singleton
public class DynamoClientConfig {
@Produces
@ApplicationScoped
public DynamoDbClient getClientDb() {
return DynamoDbClient.builder().region(Region.SA_EAST_1).build();
}我用的是Java和Quarkus。
有没有人知道它可能是什么,以及如何修复它?
发布于 2022-07-27 14:04:18
搞清楚了!我在dynamodbclient中添加了参数,它起了作用。
.httpClient(UrlConnectionHttpClient.builder().build())发布于 2022-09-13 13:47:11
此问题是由以下行为(来源)引起的:
如果在ServiceLoader上未指定HTTP,则SDK将使用ServiceLoader在类路径上查找HTTP实现。
虽然您的方法有效,但是您应该大部分时间使用httpClient而不是httpClientBuilder,这样SDK就可以为您管理httpClient生命周期。有关参考,请参阅DynamoDbClientBuilder javadoc 这里和这里。不同之处:
httpClient
此客户端在准备释放时必须由用户关闭。当服务客户端关闭时,SDK不会关闭HTTP客户端。
鉴于在httpClientBuilder情况下
生成器创建的客户端由SDK管理,在服务客户端关闭时将关闭。
https://stackoverflow.com/questions/73129078
复制相似问题