Giter Club home page Giter Club logo

azure-spring-mvc-cosmos-db-java-sql-api-samples's Introduction

Spring MVC with Azure Cosmos DB - sample

Sample e-commerce application built with Spring Boot (MVC on servlet stack) and "Spring Data Cosmos" client library for Azure Cosmos DB SQL API.

Image

Features

  • @Query annotation for finder method
  • Collection configuration with annotations(Indexing, RUs).
  • Multiple database and collections accessed from single application.
  • Auto generating UUID based IDs.
  • Spring Data Repository pattern.
  • Enabling cosmos request diagnostics
  • Directly using CosmosAsynClient from a spring application.
  • Infinite scroll with JQuery.
  • Filter by category.

Getting started

Pre-requisites

  • Java Development Kit 8.
  • An active Azure account. If you don't have one, you can sign up for a free account. Alternatively, you can use the Azure Cosmos DB Emulator for development and testing. As emulator https certificate is self signed, you need to import its certificate to java trusted cert store, explained here.
  • Maven.
  • (Optional) SLF4J is a logging facade.
  • (Optional) SLF4J binding is used to associate a specific logging framework with SLF4J.
  • Clone the repo.

Installation

  1. Update the cosmos DB endpoint, key and locations information in application.properties
  2. mvn spring-boot:run from the project base
  3. On startup the application creates 2 databases and 4 collections between them.
  4. Access the WebApp at http://localhost:81/ebooks/index
  5. You will have to create user account to access the application functionality. The registration process asks for email ID, which will be used as the login ID. Any email address is fine as long as it has a valid format.
  6. If you prefer docker:
    • mvn package
    • docker build -t /ebookstorespringbootmvc .
    • docker run -p 80:80 -e azure.cosmos.bookstore.uri=<COSMOS_ENDPOINT> -e azure.cosmos.bookstore.key=<COSMOS_KEY> -t /ebookstorespringbootmvc
    • Access the WebApp at http://localhost:81/ebooks/index

azure-spring-mvc-cosmos-db-java-sql-api-samples's People

Contributors

microsoft-github-operations[bot] avatar microsoftopensource avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.