简体   繁体   English

适用于 Azure Cosmos Documents DB 的 Java Api (SQL Api)

[英]Java Api for Azure Cosmos Documents DB (SQL Api)

I have started to work with Azure Cosmos DB Sql Api.我已经开始使用 Azure Cosmos DB Sql Api。 I have found two different Java APIs which can be used to manage this database:我发现了两种不同的 Java API 可用于管理此数据库:


com.azure::azure-cosmos com.azure::azure-cosmos

After following Quick start demo (available in the Azure portal Quick start section)遵循快速入门演示(可在 Azure 门户快速入门部分获得)

在此处输入图片说明

I have downloaded demo code, which has dependency on:我已经下载了演示代码,它依赖于:

<dependency>
    <groupId>com.azure</groupId>
    <artifactId>azure-cosmos</artifactId>
    <version>4.0.0-preview.1</version>
</dependency>

This Api is described here: azure-cosmos .这里描述了这个 Api: azure-cosmos In this Api I found couple of useful classes like CosmosClientBuilder , CosmosContainer .在这个 Api 中,我发现了几个有用的类,比如CosmosClientBuilderCosmosContainer


com.microsoft.azure::azure-documentdb com.microsoft.azure::azure-documentdb

However, after reading documentation from docs.microsoft.azure.com I found that they recommend to use com.microsoft.azure::azure-documentdb :但是,从 docs.microsoft.azure.com 阅读文档后,我发现他们建议使用com.microsoft.azure::azure-documentdb

<dependency>
    <groupId>com.microsoft.azure</groupId>
    <artifactId>azure-documentdb</artifactId>
    <version>LATEST</version>
</dependency>
<dependency>
    <groupId>com.microsoft.azure</groupId>
    <artifactId>azure-cosmosdb</artifactId>
    <version>2.6.5</version>
</dependency>

In this Api I do not see the useful CosmosClientBuilder class, and the way of creating connection to the database is little different.在这个 Api 中,我没有看到有用的CosmosClientBuilder类,创建到数据库的连接的方式也没有什么不同。


I wonder which Api is recommended to use?我想知道推荐使用哪个 Api? Do they serve different purposes?它们有不同的用途吗?

com.azure::azure-cosmos is the recommended version for new users of Azure Cosmos DB Java SDK for SQL API. com.azure::azure-cosmos 是 Azure Cosmos DB Java SDK for SQL API 新用户的推荐版本。 As you can tell from the Maven artifact ("4.0.0.preview-1") the latest release is a preview version of v4 - keep an eye out later in March for the General Availability (non-preview) release of Azure Cosmos DB Java SDK v4 for SQL API.正如您从 Maven 工件(“4.0.0.preview-1”)中可以看出的,最新版本是 v4 的预览版 - 请留意 3 月晚些时候的 Azure Cosmos DB 的正式发布(非预览版)用于 SQL API 的 Java SDK v4。 It will be under a slightly different Maven artifact name.它将在稍微不同的 Maven 工件名称下。

All of these packages are SDK updates for the same API, namely the Core (SQL) API which is recommend for best perf and support.所有这些包都是针对相同 API 的 SDK 更新,即为获得最佳性能和支持而推荐的核心 (SQL) API。

Version number is what matters.版本号很重要。 3.xx is latest stable 4.0 is preview and we're pushing people to start using 4.0. 3.xx 是最新的稳定版 4.0 是预览版,我们正在推动人们开始使用 4.0。

Here is the relation of version number to Maven artifact:这是版本号与 Maven 工件的关系:

com.azure::azure-cosmos: v4.0.x Async/Sync (public preview)

com.microsoft.azure::azure-cosmos : v3.x.x Async/Sync (stable)

com.microsoft.azure::azure-cosmosdb : v2.x.x Async (stable)

com.microsoft.azure::azure-documentdb : v2.4.7 "Legacy" Sync, deprecated (stable)

If you are confused by the many different Maven artifacts for the same SDK - this happened when Azure Cosmos DB SDK migrated into the mainline Azure SDK repo;如果您对同一 SDK 的许多不同 Maven 工件感到困惑 - 当 Azure Cosmos DB SDK 迁移到主线 Azure SDK 存储库时就会发生这种情况; we've gone through a process of refining our package names.我们经历了一个改进我们的包名称的过程。 We expect this to be stable going forward.我们预计这将在未来保持稳定。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM