我在尝试使用我拥有的凭据创建azure BlobCenter客户端时遇到错误。
凭据是storagesharedkeycredential的instanceof,终结点是string的instanceof
这是密码
public BlobContainerClient initBlobClient() {
BlobContainerClient blobContainerClient;
StorageSharedKeyCredential credential = new StorageSharedKeyCredential(ACCOUNT_NAME, ACCOUNT_KEY);
String endpoint = String.format(Locale.ROOT, "https://test.blob.core.windows.net");
// Getting the ClassDefError here
BlobServiceClient storageClient = new BlobServiceClientBuilder().endpoint(endpoint).credential(credential).buildClient();
blobContainerClient = storageClient.getBlobContainerClient(CONTAINTER_NAME);
return blobContainerClient;
}
这是它触发的堆栈跟踪
at com.fasterxml.jackson.dataformat.xml.XmlMapper.<init>(XmlMapper.java:122)
at com.azure.core.util.serializer.JacksonAdapter.<init>(JacksonAdapter.java:76)
at com.azure.core.util.serializer.JacksonAdapter.createDefaultSerializerAdapter(JacksonAdapter.java:109)
at com.azure.core.http.rest.RestProxy.createDefaultSerializer(RestProxy.java:615)
at com.azure.core.http.rest.RestProxy.create(RestProxy.java:667)
at com.azure.storage.blob.implementation.ServicesImpl.<init>(ServicesImpl.java:58)
at com.azure.storage.blob.implementation.AzureBlobStorageImpl.<init>(AzureBlobStorageImpl.java:216)
at com.azure.storage.blob.implementation.AzureBlobStorageBuilder.build(AzureBlobStorageBuilder.java:93)
at com.azure.storage.blob.BlobServiceAsyncClient.<init>(BlobServiceAsyncClient.java:108)
at com.azure.storage.blob.BlobServiceClientBuilder.buildAsyncClient(BlobServiceClientBuilder.java:109)
at com.azure.storage.blob.BlobServiceClientBuilder.buildClient(BlobServiceClientBuilder.java:82)
这些都是我拥有的。我还添加了jackson,因为stackoverflow的一条评论说这可以解决问题,但事实并非如此。
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.12.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.azure/azure-storage-blob -->
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-storage-blob</artifactId>
<version>12.9.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.azure/azure-core -->
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-core</artifactId>
<version>1.3.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.projectreactor/reactor-core -->
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
<version>3.3.4.RELEASE</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-storage</artifactId>
<version>8.6.3</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure</artifactId>
<version>1.33.0</version>
</dependency>
有人能指出是不是少了什么东西,或者是我有什么需要改变的吗?
1条答案
按热度按时间a1o7rhls1#
只有依赖
azure-storage-blob
azure存储blob sdk需要。还有一个关于创建容器的示例。
请尝试按照这个快速启动来创建maven项目。