我正在使用 SQL Api 开发 Azure Cosmos DB。我使用的 Azure SDK 来自:
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-documentdb</artifactId>
<version>2.4.7</version>
</dependency>
为了将项目插入集合中。
DocumentClient documentClient = setupDocumentClient();
ResourceResponse<Document> document = documentClient.createDocument("/dbs/" + databaseName + "/colls/" + colName, entity, new RequestOptions(), true);
我遇到异常:
com.microsoft.azure.documentdb.DocumentClientException: Message: {"Errors":["Date header doesn't conform to the required format. Please ensure that the time is provided in GMT and conforms to RFC 1123 date-time specifications.","Date header doesn't conform to the required format. Please ensure that the time is provided in GMT and conforms to RFC 1123 date-time specifications."]}
奇怪的是,我在另一个项目中使用了相同的代码,并且它正常工作,没有出现此异常,并且数据已正确插入到 Azure Cosmos DB 中。也许有人遇到过这个问题并找到了解决方案?
最佳答案
我通过添加以下内容在代码中修复了此问题:
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>LATEST</version>
</dependency>
此后,我运行mvn clean install,异常消失了。
显然我的项目的其他依赖项之一引用了 joda-time 的旧依赖项。
关于java - com.microsoft.azure.documentdb.DocumentClientException 日期 header 不符合所需的格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60541362/