跟随https://docs.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)
2条答案
按热度按时间cx6n0qe31#
找不到httpclient时将发生错误。它似乎与代码无关。尝试检查是否遵循文档中的步骤。
我在app.java中尝试了以下代码,效果很好。
如果删除
credential()
,它将返回此错误:resourcenotfound指定的资源不存在。无凭据访问公共blob:
qncylg1j2#
它的工作原理是:
采取https://github.com/azure-samples/azure-sdk-for-java-storage-blob-upload-download
将pom中的azure版本更改为12.9
导出azure\u storage\u account=azuremlexamples
编辑如下
运行mvn compileexec:java
输出为:
正在列出容器中的blob:https://azuremlexamples.blob.core.windows.net/datasets 这是blob名称:criteo-uplevation-v2.1.csv.gz这是blob名称:iris.csv