Skip to content

Latest commit

 

History

History
65 lines (43 loc) · 3.35 KB

File metadata and controls

65 lines (43 loc) · 3.35 KB

Overview

This sample project demonstrates how to use Azure DocumentDB via Spring Boot Starter azure-documentdb-spring-boot-starter to store data in and retrieve data from your Azure Cosmos DB by using the DocumentDB API.

Prerequisites

Quick Start

Create an Azure Cosmos DB on Azure

  1. Go to Azure portal and click +New .
  2. Click Databases, and then click Azure Cosmos DB to create your database.
  3. Navigate to the database you have created, and click Access keys and copy your URI and access keys for your database.

Config the sample

  1. Navigate to src/main/resources and open application.properties.
  2. replace below properties in application.properties with information of your database.
    azure.documentdb.uri=your-documentdb-uri
    azure.documentdb.key=your-documentdb-key
    azure.documentdb.database=your-documentdb-databasename

Run the sample

  1. Change directory to folder azure-documentdb-spring-boot-sample.

  2. Run below commands.

    • Use Maven

      mvn package
      java -jar target/azure-ducumentdb-spring-boot-sample-0.0.1-SNAPSHOT.jar
      
    • Use Gradle

      gradle bootRepackage
      java -jar build/libs/azure-ducumentdb-spring-boot-sample-0.0.1-SNAPSHOT.jar
      

Known issue

Directly running the sample app from IDE IntelliJ or Eclipse has below security exception if using the released starter. The root cause is that the release spring-data-azure-documentdb jar is code-signed by us. We're working actively to resolve this issue.

Caused by: java.lang.SecurityException: class "com.microsoft.azure.sample.User_Accessor_yhb3bq"'s signer information does not match signer information of other classes in the same package
	at java.lang.ClassLoader.checkCerts(ClassLoader.java:898) ~[na:1.8.0_131]
	at java.lang.ClassLoader.preDefineClass(ClassLoader.java:668) ~[na:1.8.0_131]
	at java.lang.ClassLoader.defineClass(ClassLoader.java:761) ~[na:1.8.0_131]

If com.fasterxml.jackson.databind.JsonMappingException is thrown during deserialization, with error message Can not construct instance of {your.pojo.class}: no suitable constructor found, can not deserialize from Object value (missing default constructor..., add Lombok annotatations @Data and @AllArgsConstructor for your POJO class, or use Jackson annotations @JsonCreator and @JsonProperty for the full argument constructor.

More details

Please refer to this article for the tutorial about how to use the Spring Boot Starter with Azure Cosmos DB DocumentDB API.