Home » Archives for Shubhra Srivastava

Author Archives: Shubhra Srivastava

Shubhra is a software professional and founder of ProgrammerGirl. She has a great experience with Java/J2EE technologies and frameworks. She loves the amalgam of programming and coffee :)

JPA @Embeddable and @Embedded

java-interview-questions-answers

Introduction: As an object-oriented developer, we want to avoid having larger classes with tons of unrelatable fields. And so, we might often feel the need to represent a JPA Entity using multiple objects. In this quick tutorial, we’ll learn how to achieve it using @Embedded and @Embeddable annotations in JPA or Hibernate. Context Buildup: Let’s say we have a person table with ...

Read More »

Working with kubectl in Kubernetes

Kubectl is a command-line tool that helps us interact with our Kubernetes API server. In turn, it helps us manage our K8s cluster. In this quick tutorial, we’ll learn and explore some commonly used kubectl commands. Working with kubectl: Let’s look at kubectl‘s general syntax: Shell 1 kubectl [operation] [resource-type] [resource-name] [flags] When we don’t specify the resource name, it ...

Read More »

Kubernetes: An Introduction

Introduction: In this tutorial, we’ll introduce you to Kubernetes and will discuss its architecture. As a prerequisite, it’s good to have some basic knowledge of the container world. Kubernetes & its Architecture: Kubernetes, popularly known as K8s, is an open-source container orchestration engine for microservices-based containerized applications. A K8s cluster comprises of a master and multiple worker nodes: The master ...

Read More »

Spring @RequestParam Annotation

spring-interview-questions-answers

Introduction: Spring @RequestParam annotation can be used to extract the query parameters in a handler method. In this quick tutorial, we’ll learn its usage. @RequestParam Annotation: Let’s first expose an API which returns a list of users with a given first name and age: @RestController public class UserController {     ...     @GetMapping("/users")     public List<User> getUsers(@RequestParam String firstName, @RequestParam int age) {         return ...

Read More »

Spring @Primary Annotation

spring-interview-questions-answers

Introduction: Spring @Primary annotation is used to give a higher preference to the marked bean when multiple beans of the same type exist. Spring, by default, auto-wires by type. And so, when Spring attempts to autowire and there are multiple beans of the same type, we’ll get a NoUniqueBeanDefinitionException: Caused by: org.springframework.beans.factory.NoUniqueBeanDefinitionException   : No qualifying bean of type [com.programmergirl.Person]   is ...

Read More »

Spring @Lazy Annotation

spring-interview-questions-answers

Introduction: The Spring framework, by default, loads and eagerly initializes all beans at the application startup itself. In our application, we might have some pretty resource-intensive beans. We’ll prefer to load such beans on a need basis. We can achieve this using the Spring @Lazy annotation. In this tutorial, we’ll learn how to use @Lazy annotation to lazily load our ...

Read More »

Spring @Order Annotation

spring-interview-questions-answers

Introduction: The Spring @Order annotation was first introduced in Spring 2.0. It was then used only to define the order among the AspectJ advices. Later in Spring 4.0, the implementation of this annotation was further improved a bit. Since then, it also supports ordering of Spring components or beans in a collection like a Java array or a List. This ...

Read More »

Spring Boot: Building a RESTful Web Application

spring-interview-questions-answers

Introduction: REST stands for Representational State Transfer and is an architectural guideline for API design. We assume that you already have a background in building RESTful APIs. In this tutorial, we’ll design a simple Spring Boot RESTful web application, exposing a few REST endpoints. Project Setup: Let’s start by downloading the project template via Spring Initializr: We only need to ...

Read More »

Spring Boot with H2 Database

spring-interview-questions-answers

In this quick tutorial, we’ll bootstrap a simple Spring Boot application backed by an in-memory H2 database. We’ll use the Spring Data JPA to interact with our database. Project Setup: Firstly, let’s generate our project template using Spring Initializr: On clicking the ‘Generate the project’ link, our project files will get downloaded. Now, if we look closely at the generated ...

Read More »