![](/img/trans.png)
[英]UnknownHostException while connecting to Azure Cosmos DB from Java code
[英]Connecting locally to Azure Cosmos DB
I'm creating an Azure Function that downloads the XML of a given URL and stores the document in Cosmos DB at predefined times. 目前,我使用 Java 在 VSC 中本地開發應用程序,並且還使用 Cosmos DB 模擬器。 在我的代碼中,我使用以下代碼實例化了一個 CosmosClient 對象:
private static CosmosClient cosmosClient = new CosmosClientBuilder().endpoint("https://localhost:8081")
.key("C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==").consistencyLevel(ConsistencyLevel.EVENTUAL).buildClient();
每當我運行我的代碼時,程序都會執行,但在 buildClient() 方法結束后會創建大量線程,導致以下錯誤消息:
終端錯誤信息:
我從模擬器的 web 表面拿走了 URL 和密鑰,那么我的錯誤在哪里? 我是否必須提供其他憑據。
已解決:我犯了一個錯誤,我將 Azure Cosmos Emulator 證書添加到錯誤的 java 密鑰庫中,作為提到的Azure 指南。 我的系統變量僅在我的用戶版本 JVM 中顯示,而我將證書加載到全局 JVM 副本,因此導致簽名失敗。 這篇文章提供了一個完整的解決方案。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.