请求加载默认的HttpClient提供程序,但在类路径上找不到



我正试图使用Azure存储blob库从Azure存储blob中删除一些blob,我的应用程序部署在数据块中作为一个火花作业。此外,我的代码在本地机器上运行正常

我的错误如下:

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

我的代码:

val accountName: String = spark.conf.get("AZURE_BLOB_STORAGE_ACCOUNT_NAME")
val accountKey: String =  spark.conf.get(s"fs.azure.account.key.$accountName.blob.core.windows.net")
val endpoint = "https://" + accountName + ".blob.core.windows.net"
val credential = new StorageSharedKeyCredential(accountName, accountKey)
val client = new BlobServiceClientBuilder().endpoint(endpoint).credential(credential).buildClient
val containerClient = client.getBlobContainerClient(containerName)
containerClient
.listBlobsByHierarchy(s"$folderName/")
.forEach(blob =>
containerClient
.getBlobClient(blob.getName)
.deleteIfExists()
)

有解决这个问题的办法吗?

谢谢

您可能在build.sbt:中配置了以下合并策略

case PathList("META-INF", xs @ _*) => MergeStrategy.discard

请检查您的jar中是否有META-INF/services目录。

最新更新