Code Monkey home page Code Monkey logo

spring-data-cassandra-on-azure-extension-v3's Introduction

page_type languages products description urlFragment
sample
java
azure
This sample shows how to use Spring Data Apache Cassandra module with Azure CosmosDB service.
spring-data-cassandra-on-azure

Spring Data Apache Cassandra on Azure

This sample shows how to use Spring Data Apache Cassandra module with Azure CosmosDB service.

TOC

Prerequisite

  • Azure Account
  • JDK 1.8 or above
  • Maven 3.0 or above
  • Curl

Build

  1. Create a Cassandra account with Azure CosmosDB by following tutorial at here.

  2. Use Data Explorer from Azure Portal to create a keyspace named mykeyspace.

  3. Find application.properties at src/main/resources and fill in below properties.

    spring.data.cassandra.contact-points=<replace with your Cassandra contact point>
    spring.data.cassandra.port=10350
    spring.data.cassandra.username=<replace with your Cassandra account user name>
    spring.data.cassandra.password=<replace with your Cassandra account password>
    
  4. Build the sample application into a JAR package by running below command.

    mvn clean package

Run

Following below steps to run and test the sample application.

  1. Run application.

    java -jar target/spring-data-cassandra-on-azure-0.1.0-SNAPSHOT.jar
  2. Create new users by running below command.

    curl -s -d '{"name":"Tom","species":"cat"}' -H "Content-Type: application/json" -X POST http://localhost:8080/pets
    curl -s -d '{"name":"Jerry","species":"mouse"}' -H "Content-Type: application/json" -X POST http://localhost:8080/pets

    Sample output is as below.

    Added Pet(id=1, name=Tom, species=cat).
    ...
    Added Pet(id=2, name=Jerry, species=mouse).
    
  3. Get all existing pets by running below command.

    curl -s http://localhost:8080/pets

    Sample output is as below.

    [{"id":1,"name":"Tom","species":"cat"},{"id":2,"name":"Jerry","species":"mouse"}]

spring-data-cassandra-on-azure-extension-v3'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.