gpt4 book ai didi

java - 适用于 blob 的 Azure Java SDK - 发出了加载默认 HttpClient 提供程序的请求,但在类路径中找不到该提供程序

转载 作者:行者123 更新时间:2023-12-03 05:31:20 26 4
gpt4 key购买 nike

已关注 https://learn.microsoft.com/en-us/azure/storage/blobs/storage-quickstart-blobs-java?tabs=powershell收到此错误:

Caused by: java.lang.IllegalStateException: A request was made to load the default HttpClient provider but one could not be found on the classpath. If you are using a dependency manager, consider including a dependency on azure-core-http-netty or azure-core-http-okhttp. Depending on your existing dependencies, you have the choice of Netty or OkHttp implementations. Additionally, refer to https://aka.ms/azsdk/java/docs/custom-httpclient to learn about writing your own implementation.
at com.azure.core.implementation.http.HttpClientProviders.createInstance(HttpClientProviders.java:37)
at com.azure.core.http.HttpClient.createDefault(HttpClient.java:27)
at com.azure.core.http.HttpPipelineBuilder.build(HttpPipelineBuilder.java:60)
at com.azure.storage.blob.implementation.util.BuilderHelper.buildPipeline(BuilderHelper.java:110)
at com.azure.storage.blob.BlobServiceClientBuilder.buildAsyncClient(BlobServiceClientBuilder.java:107)
at com.azure.storage.blob.BlobServiceClientBuilder.buildClient(BlobServiceClientBuilder.java:84)

最佳答案

error找不到 HttpClient 时会发生。貌似和代码无关。尝试检查您是否按照文档中的步骤操作。

我在 App.java 中尝试了以下代码,效果很好。

StorageSharedKeyCredential credential = new StorageSharedKeyCredential(accountName, accountKey);
BlobServiceClient blobServiceClient = new BlobServiceClientBuilder().endpoint(endpoint).credential(credential).buildClient();

enter image description here

如果删除credential(),则会返回此错误:ResourceNotFound 指定的资源不存在

无需凭据即可访问公共(public) blob:

enter image description here

关于java - 适用于 blob 的 Azure Java SDK - 发出了加载默认 HttpClient 提供程序的请求,但在类路径中找不到该提供程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65135299/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com