java - com.microsoft.azure.documentdb.DocumentClientException 日期 header 不符合所需的格式

标签 java azure azure-cosmosdb azure-cosmosdb-sqlapi azure-java-sdk

我正在使用 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/

相关文章:

java - 在 CSS 中定位 JSF 2.0 组件

java - 如何从命令提示符编译实现包的java程序

mongodb - Azure cosmos DB 3.6 Mongo 不支持具有嵌入字段的复合索引

Java 中的 Java 泛型方法调用

java - 尝试应用 AttributeConverter 时出错

asp.net - Windows Azure 我可以在同一个超小型实例或小型实例上运行多个网站吗

c# - Azure Blob 客户端设置较短的超时

c# - Azure Key Vault 中的应用程序设置配置部分

azure - Cosmos DB - 删除文档

mongodb - Microsoft 的 Azure DocumentDB 可以用作 Meteor 的后端吗?