How to create a SpringBoot Gemfire RestfulApi

Spring Data REST provides a mechanics for creating and retrieving an Object from Gemfire storage.
In the article, JavaSampleApproach will introduce you how to create a Gemfire RestfulAPI.

Related Articles:
How to start Embedded Gemfire Application with SpringBoot
Infinispan Cache Solution | Spring Cache | Spring Boot

I. Technologies for SpringBoot Gemfire Restful Api

– Java 1.8
– Maven 3.3.9
– Spring Tool Suite – Version 3.8.1.RELEASE

II. Overview
1. Project Structure

springboot gemfire restfulapi project structure

2. Step to do

– Create a Spring Boot project
– Create a Java Model class
– Config Gemfire storage
– Create a Gemfire repository
– Run & Check result

III. Practices
1. Create a Spring Boot project

Open Spring Tool Suite, on main menu, choose File->New->Spring Starter Project, input project info, press Next then Finish, spring boot project will be created successfully.

Gemfire & Restful dependencies:

Open pom.xml file, add needed dependencies:

2. Create a Java Model class

– Create a simple Java model:

3. Config Gemfire storage

Config CacheFactoryBean and LocalRegionFactoryBean

4. Create a Gemfire repository

Create a Gemfire repository interface by extends CrudRepository Spring interface.
@RepositoryRestResource is optional, it is used to redefine a default path.

In main class, enable GemfireRepositories by

5. Run & Check result

Run project with Spring Boot Application mode.
Test time:

– Store 2 customers to Gemfire Caching:
springboot gemfire restfulapi - post entity

springboot gemfire restfulapi

– Retrieve all customers from Gemfire:
springboot gemfire restfulapi - get all

– Search RestfulAPI:
springboot  gemfire restfulapi search api

– Retrieve a customer from Gemfire:
 springboot gemfire restfulapi - get customer by id

– Find a customer by firstname:
springboot gemfire restfulapi - findbyfirstname

– Find a customer by lastname:
springboot gemfire restfulapi - findbylastname

– Find customers by age:
springboot gemfire restfulapi  - findbyagegreaterthan

springboot  gemfire restfulapi - findbyagelessthan

IV. Sourcecode


By grokonez | December 31, 2016.

Last updated on June 4, 2017.

Related Posts

1 thought on “How to create a SpringBoot Gemfire RestfulApi”

  1. Good post.

    I have few queries here:
    1. How to view the saved data on UI like mysql, oracle, etc… ?
    2. How to deal with different tables/entities if they are having mappings ?
    3. How we can use this in Micro services architecture ?


Got Something To Say:

Your email address will not be published. Required fields are marked *