Spring Data with Spring Boot


This blog will show how to integrate Spring Data with Spring Boot. The flow will be from the Rest Controller which will wire the service to make call to JPA Repository as shown below.

Maven Dependency

Initialize the Spring Boot Application using start.spring.io with Web and JPA dependency added to it.

Need to add below dependency to support Spring Data JPA and embedded h2 database

  1. spring-boot-starter-data-jpa [ org.springframework.boot ]
  2. h2 [ com.h2database ]

Repository Changes

Define an interface that extends JpaRepository for the entity along with the primary key. Here, we have an Employee Entity and the primary key data type for the entity is String.

Service Changes

Inject the Repo as dependency in Service Layer and make use of findAll() method and getById method to return the list of employees or return a specific employee

Entity Changes

Define a model, that maps entity bean to a table.

Note : Please add @JsonIgnoreProperties to override below exception

com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serialiser found for class org.hibernate.proxy.pojo.bytebuddy.ByteBuddyInterceptor

Starter Changes

Need to add below annotation

  1. @EnableJpaRepositories
  2. @EnableEntityScan

SQL Changes

Place the SQL files in main/resources folder to load it into DB , on application startup

Config Changes

H2 Console Dashboard

We can able to access the H2 dashboard @ localhost:8095/h2-console ( Here the port no specified in application.properties should match )

And the JDBC URL should be : jdbc:h2:mem:testdb

Then click on test connection, to see its successful.


Test the endpoint through Postman

Happy Learning !

Bharathy Poovalingam

Configuring Swagger in Spring Boot Application

SpringBoot Initializr:

Initialize a Sample Spring Boot Application using Spring Initializr : https://start.spring.io/

Key in the Group, artifact id and the name for your sample project .

Choose your favourite language, it can be Java/Kotlin/Groovy.

Also choose the language version, Packaging option and the Project to be built in. It can be Maven or Gradle.

For this demo, I have Chosen Java 8 for language , Maven as a build tool and packaging as jar

Once you have clicked generate, it will generate a zip file with required dependencies been added to the pom.xml file. Import it as a Maven project in your IDE. I have chosen Eclipse for this demo.

Maven Dependency

Add the SpringFox Swagger Dependency as below to the pom.xml

Note: For Spring boot 3 version, adding “springfox-boot-starter” dependency is enough and we don’t need to add swagger ui dependency and also not to include @EnableSwagger2 in the starter class.

Then run command :mvn clean install to download the swagger dependency to your project.

Code Changes

To enable Swagger in the Spring Boot Application, need to make code changes in below sections

Spring Boot Starter Class

Need to define a Bean “Docket” to customize the Swagger Documentation. Say if we access the swagger UI : http://localhost:<<PORT_NO>>/swagger-ui/index.html. It will provide api docs for the controller been defined along with the error controllers. To restrict API definition to the controllers been defined in our application, need to have this docket Bean with the PathSelectors and RequestHandlerSelectors point to the controllers defined for our application as below. Here I restrict the scan to the package “com.nikki.demo.controller” to scan for this controller package

Spring Rest Controller

Then to have the controller APIs to display more additional information about the endpoint been exposed, can add API operation annotation to it.

Here each endpoint been annotated with @ApiOperation to give more details about the endpoint

Accessing the Swagger UI

Then, hit the Swagger UI as below ( after running your application as mvn clean spring-boot:run )

Happy Learning !

Bharathy Poovalingam


GCP Data Engineer : Cloud SQL/Cloud Spanner

Storage Services in GCP

This blog will focus on Cloud Storage service in GCP.

Object Storage ( Buckets ) : To store unstructured data and for archival use-cases.

Instance Storage ( Persistent Disks ) : To work with VMs, Kubernetes Clusters

SQL ( Cloud SQL, Cloud Spanner ) : For Relational DB use-case and for transaction support

NoSQL ( BigTable, DataStore ) : For storing non-relational data

Analytic ( Cloud BigQuery ) : For Data warehousing

Cloud Storage

Cloud Storage helps in storing unstructured data , by having files or images been stored into buckets in GCS.

Login to cloud console : https://console.cloud.google.com/storage and move to Storage service section.

While creating a bucket, below are the storage class type options provided

Once bucket got created, user can login to the console to upload files or folders to move into the bucket.

Loading Data into Storage

For less Volume of data, we can use one of the following

gsutil : command line utility to copy files into bucket, to create bucket and to move files. Activate Cloud Shell from Cloud Console ( appear on the right corner with image “>”

Cloud Console


For Bulk and large volume of data, we can use

Cloud Storage Transfer : Moving data from On Premises and other cloud services, to move data between cloud storage buckets, transfer more than 1Tb from on-premises. Supports one-time and recurring transfers.

Transfer Appliance : High Capacity storage server, to move large volumes of data (100 Tb)


Data stored in GCP is encrypted by default. While creating bucket, under advanced settings, you can chose the option to encryption as below.

Data uploaded into GCP is divided into multiple data chunks, each been encrypted with its own key ( Data Encryption Key : DEK ) and data encryption keys are been encrypted using Key Encryption Key ( KEK ) which gets stored in KMS ( Key Management Service )


Uniform Bucket Level Access : Recommended, uses IAM (Identity and Access Management ), permission at Bucket Level

Fine-grained Access : Uses ACLs, permission apply at both Bucket and Object Level

Signed URLs

Time Limit read or write access to an object ( short-term access )

Allow access to those without IAM authorizations. Generate signed url comprise of two steps

Creating Service Account Key with relevant permission

Using gsutil command to generate the url passing the service account key as json and the time for url to be accessed using param : “-d”

Signed Policy Documents

Specify what can be loaded to a bucket with a form post

Allow greater control over size,content type and other upload characteristics than signed urls.

Lifecycle Policy Management

It consist of Actions and Conditions. What is the action to be performed on the bucket when the condition met

Action can be moving object from one storage class to another one

Actions executed when condition applies eg : Change Storage class based on age, Delete object based on date, Purge versions etc

Happy Learning !

Bharathy Poovalingam

#GCP #Learning #Data Engineer #CloudStorage

GCP Learning Series _ App Engine Part 3


This blog will show how to deploy image from Container Registry to Google App Engine


To deploy an app into App Engine, need to have app.yaml file configured as below

Then run command :

gcloud app deploy — image-url=gcr.io/gcpnikki/appengine/demo:latest

After successful deployment, we can navigate to the AppEngine dashboard ( Instances/Services ) to review the changes

gcloud app browse

Using gcloud app browse command to view the application been deployed and specify the endpoint been exposed, can able to hit the endpoints

Happy Learning !

Bharathy Poovalingam

#GCP #Learning #Serverless #AppEngine

GCP Learning Series _ App Engine Part 2


This blog will show how to setup Cloud SDK in your local machine, configuring docker , create docker image and push it to Container Registry

Cloud SDK Installation

To install Cloud SDK, Python3 is pre-requisite.

Please install Python, using brew

brew install python3

Then download the tar file : google-cloud-sdk-350.0.0-darwin-x86_64.tar

Unzip it and then run below command to do Cloud SDK installation

Cloud Authentication

Need to run below command to do authentication

gcloud auth login

the above command, will open up the gcloud console and need to give your consent there to access gcloud console

Building a sample application and push it to Container Registry


To build and dockerize the application, please refer to : https://medium.com/@bharathy.poovalingam/spring-boot-with-docker-d4129a353f87

Note : here , need to tag the image, that match to gcr registry as shown below

Syntax : gcr.io/PROJ_ID/folder/image_name

Authorizing Docker

Need to run below command to authorize docker to push image to Google Cloud Container Registry

gcloud auth configure-docker

Pushing the image to Container Registry

Login to gcloud console and navigate to Container Registry section, to view the image been pushed there.

to be continued… ( Deploying the image to Google App Engine )

Happy Learning !

Bharathy Poovalingam

#GCP #Learning #Serverless #AppEngine

GCP Learning Series _App Engine Part 1


This App Engine series comprise of three parts

  1. Overview of App Engine (Part 1 )
  2. Cloud SDK Setup , Configuring and Authorizing Docker to push image to Google Container Registry ( gcr ) ( Part 2 )
  3. Deploying the image from gcr into App Engine Flexible environment (Part 3 )

App Engine is a Platform-as-a-Service. It means that you simply deploy your code, and the platform does everything else for you. For example, if your app becomes very successful, App Engine will automatically create more instances to handle the increased volume. ( Scaling support )

Note : It’s a PaaS (service) like Elastic Beanstalk in AWS Cloud

Compute Choices

Compute Engine ( IaaS ) : To create VMs and have more control ( Lift and Swift )

GKE ( CaaS ) : To deploy images into container and have control in managing the cluster ( Container Clusters )

App Engine ( PaaS ) : Managed Service by GCP

Cloud Functions ( FaaS) : Serverless , Event Driven Architecture

Managed Service (Serverless)
Build and Deploy Apps quickly, built-in support for load balancing and autoscaling
Pay As You Go
Focus on Code, as App Engine is a managed service from GCP, which will take care of provisioning Infra Structure
Choose between Standard and Flexible environment
Traffic Splitting/Versioning

App Engine Variance

App Engine comes in two flavours. One is Standard Environment and another one is Flexible Environment

App Engine Standard Environment

Google App Engine (Standard) is like a read-only sandboxed folder where you upload code to execute from and don’t worry about the rest (yes: read-only — there are a fixed set of libraries installed for you and you cannot deploy 3rd party libraries at will). DNS / Sub-domains etc is so much easier to map.


Instance can be startup in milliseconds.

It provides Manual, basic and automatic scaling.


Lacks support for 3rd Party Library

Minimal Language Support

Supported Runtimes

App Engine Flexible Environment

Google App Engine (Flexible) is in fact like a whole file-system (not just a locked down folder), where you have more power than the Standard engine, e.g. you have read/write permissions, (but less compared to a Compute Engine). In GAE standard you have a fixed set of libraries installed for you and you cannot deploy 3rd party libraries at will. In the Flexible environment you can install whatever library your app depends on, including custom build environments (such as Python 3).


Customizable Stack

Support for 3rd library


Can take minutes to start

Need to have one instance running all time, can not be bring down to zero. It might cost more compared to Standard environment

Supported Runtimes

Note : Both Standard and Flexible environment runs on Container based environment, while Standard container is maintained by Google Proprietary and Flexible container relies on Docker one.

GCP Console

Login to GCP Console, click on Hamburger Menu and navigate to Serverless section and click on App Engine. You will be redirected to AppEngine dashboard.

to be continued … ( Cloud SDK Installation , GCloud Authentication, Container Registry) . Stay Tuned !

Happy Learning !

Bharathy Poovalingam

#GCP #Serverless #AppEngine #Learning

Related Course:

Architecting Scalable Web Applications using Google App Engine ( Janani Ravi / Pluralsight )