我正在尝试将文件上传到Azure blob存储中,但出现以下错误。
Spring Boot版本是2.1.RELEASE
java.lang.NoClassDefFoundError: io/netty/handler/ssl/SslContextBuilder\n\tat com.microsoft.rest.v2.http.SharedChannelPool.<init>(SharedChannelPool.java:83)\n\
要上传的代码如下,该代码是从Azure示例中复制的。
@Service
class AzureBlobService(val azureSettings: AzureSettings) {
fun upload(file: MultipartFile): String {
val credential = SharedKeyCredentials(azureSettings.storage!!.accountName, azureSettings.storage!!.accountKey)
val pipeline = StorageURL.createPipeline(credential, PipelineOptions())
/*
From the Azure portal, get your Storage account blob service URL endpoint.
The URL typically looks like this:
*/
val u = URL(String.format(Locale.ROOT, "https://%s.blob.core.windows.net", azureSettings.storage!!.accountName))
// Create a ServiceURL object that wraps the service URL and a request pipeline.
val serviceURL = ServiceURL(u, pipeline)
// Now you can use the ServiceURL to perform various container and blob operations.
// This example shows several common operations just to get you started.
/*
Create a URL that references a to-be-created container in your Azure Storage account. This returns a
ContainerURL object that wraps the container's URL and a request pipeline (inherited from serviceURL).
Note that container names require lowercase.
*/
val containerURL = serviceURL.createContainerURL(azureSettings.storage!!.container)
/*
Create a URL that references a to-be-created blob in your Azure Storage account's container.
This returns a BlockBlobURL object that wraps the blob's URl and a request pipeline
(inherited from containerURL). Note that blob names can be mixed case.
*/
val blobURL = containerURL.createBlockBlobURL(file.name)
blobURL.upload(Flowable.just(ByteBuffer.wrap(file.bytes)), file.size, null, null, null, null)
return blobURL.toString()
}
}
有什么想法吗? 谢谢