Wednesday, August 30, 2023

13 Spring Boot Actuator Interview Questions Answers for 5 Years Experienced

If you have used Spring Boot, you may know that Spring Boot is all about convenience, and the Spring Boot actuator is one of such features that provides a convenient way to interact with your app using HTTP and JMX. It's also essential from the Spring Boot interview point of view. While I did include some Spring Boot Actuator questions in my earlier post about frequently sked Spring boot interview questions, many of you asked for more questions to cover Spring Boot Actuator in depth, so I decided to write a separate article. In this article, we will see some popular Spring boot Actuator interview questions and, along the way, learn more about this helpful Spring boot Feature

Top 15 Spring Data JPA Interview Questions with Answers

Hello guys, If you are preparing for a Spring developer interview and looking for some Spring Data JPA Interview questions then you have come to the right place. Earlier, I have shared frequently asked interview questions on Spring Boot, Spring Cloud, Microservices, and Spring MVC in general, and in this article, I will share frequently asked Spring Data JPA Interview Questions with Answers for Java developers. Spring is one of the most popular and widely used frameworks. Spring Data JPA is an important part of the framework as it makes working with JPA or any JPA implementation like Hibernate easier.  

Tuesday, August 29, 2023

Difference between Spring vs SpringBoot Framework in Java

Hello guys, if you have been doing Java development then you would have definitely come across both Spring and Spring Boot framework These two Java frameworks have taken the software development world by storm and have become the go-to tools for building all kinds of applications. But what exactly are Spring and Spring Boot, and how do they differ from one another? This is one of the common questions which many Java programmer ask, particularly those who are starting with software development or new to Java world. In the past, I have shared several Spring and Spring boot articles, courses, books, projects, and interview questions but in this article, I am going to answer what exactly is Spring and Spring Boot and what is the difference between them? This will also help you to decide  when to use Spring Framework or Spring Boot for Java application development. 

How to access configuration values from application.properties file in Spring Boot? Example Tutorial

Hello guys, if you are wondering how to access a value defined in your spring application configuration file then you are not alone, many Java developer face the same challenge. How to access a value defined in the application.properties file in Spring Boot is a common question that arises when you dealing with large software applications. In software applications, you need to have different environments for the QA, production, and local. So as a solution for this, you can use different configurations and update the files separately without affecting other environments by using property files.

Top 18 Spring Cloud Interview Questions for Java Developers [with Answers]

Hello guys, If you are preparing for Java and Spring Boot Interview and looking for some Spring Cloud interview questions then you have come to the right place. Earlier, I have shared 15 Spring Boot Interview questions and today, I am going to share 15 Spring cloud interview questions for Java developers. These questions are good to revise essential Spring cloud concepts before interviews. Today is the world of cloud computing and most of the new Java development is happening on Cloud like AWS, GCP, and Azure. That's why it's very important for Java developers to learn about cloud and frameworks and libraries which support cloud-native development in Java, like Spring Cloud from Spring project.

Saturday, August 26, 2023

Difference between JpaREpository, CrudREpository, and PagingAndSortingRepository

Hello and welcome to my blog post. In this article, we will delve into the world of Spring Data repositories and explore the key differences between three commonly used interfaces: JpaRepository, CrudRepository, and PagingAndSortingRepository. If you're a Spring Boot developer working with databases, understanding the distinctions between these interfaces is crucial for efficient data management. So let's dive right in and uncover the unique features and use cases of each repository interface.

Top 5 Free HTML and CSS Courses for Beginners to Learn in 2024 - Best of Lot

Hello guys, if you want to learn HTML and CSS and looking for free resources then you have come to the right place. HTML and CSS are two pillars of web development, they are used to create web pages you see every day. HTML provides the structure to your web page, and CSS gives them the style to look better. If you want to become a front-end web developer or web designer, then a good knowledge of HTML and CSS is a must. Even though modern-day web development is all about framework and library, like  Angular and React, you still need to know HTML and CSS to understanding what's going on and troubleshoot any issue you face while developing a web application. Btw, JavaScript is another pillar of web development, but we'll not discuss this article. I have already shared some good books and courses to learn JavaScript before

Tuesday, August 22, 2023

Difference between @AutoWired and @Qualifier in Spring Framework?

Hello guys, if you are preparing for Spring Framework or Spring Boot interviews then you should always prepare comparison questions like what is difference between @Qualifier and @AutoWired annotation in Spring? This kind of questions are good to demonstrate not only your knowledge but also how well you understand them and its also your chance to impress the interviewer. In the past, I have answered @Bean vs @Component and @Controller vs @RestController annotation and in this article, I am going to explain you the difference between @Autowired and @Qualifier in Spring Framework. 

Monday, August 21, 2023

What is @Conditional annotation in Spring Framework? Example Tutorial

Hello guys, if you want to know what is @Conditional annotation in Spring Framework and Spring Boot, and how to use it then you have come to the right place. Earlier, I have shared best free courses to learn Spring Framework and Spring Boot, and in this article, you'll learn what they are, how to use them with practical examples. Spring 4.0 introduced the @Conditional annotation that is used for conditional checking for bean registration. This annotation offers more support than the @Profile annotation provided by the spring framework and most of the Spring Boot matching is attributed to this annotation. It allows you to setup features based upon certain conditions like presence of a class in classparth or a JAR File which is how Spring Boot Auto-configuration works.

Saturday, August 19, 2023

Difference between @Controller vs @RestController in Spring Framework

Hello and welcome to the blog post. If you are preparing for Java or Spring Boot interview, you may have come across this topic. In this article, we are going to have a look at the difference between @Controller and @RestController annotation. Let's understand with the help of an example.
Spring Framework is a popular open-source application framework that provides infrastructure support for developing Java applications. One of the essential components of Spring Framework is the controller, which is used to handle HTTP requests and provide responses to clients. In Spring, there are two types of controllers: @Controller and @RestController.

Friday, August 18, 2023

How to convert ByteBuffer to String in Java [Example]

You can easily convert ByteBuffer to String in Java if you know how to convert byte array to String. Why? because it's very easy to convert ByteBuffer to a byte array and vice versa. All you need to do is call the ByteBuffer.array() method, it will return you the byte array used by java.nio.ByteBuffer class, later you can easily create String from that byte array. Though always remember to provide correct character encoding while converting byte array to String.

How to Convert Byte array to String in Java with Example

There are multiple ways to convert a byte array to String in Java but the most straightforward way is to use the String constructor which accepts a byte array i.e. new String(byte []) , but the key thing to remember is character encoding. Since bytes are binary data but String is character data, it's very important to know the original character encoding of the text from which byte array has created. If you use a different character encoding, you will not get the original String back. For example, if you have read that byte array from a file which was encoded in "ISO-8859-1" and you have not provided any character encoding while converting byte array to String using new String() constructor then it's not guaranteed that you will get the same text back? Why? because new String() by default uses platform's default encoding (e.g. Linux machine where your JVM is running), which could be different than "ISO-8859-1".

Thursday, August 17, 2023

2 Ways to Print Custom String Value of Java Enum

We all know that how powerful the enumeration type in Java is, and one of the main strengths of enum is that they can implement an interface, they can have an instance variable and you can also override any method inside enum instance. In Java programs, we often need to convert Enum to String type, sometimes just to print values in the log file and other times for storing log into the database.  By default, when you print an enum constant, it prints its literal value e.g. if the name of the enum instance is RED, then it will print RED. This is also the value that is returned by the name() method of java.lang.Enum class. But, there are situations when we want a custom String value for an enum constant. 

How to compare String Objects in Java [Example Tutorial]

The String is a special class in Java, so is String comparison. When I say comparing String variables, it can be either to compare two String objects to check if they are the same, i.e. contains the same characters, or compare them alphabetically to check which comes first or second. In this article, we are going to talk about the right way of comparing String variables, but what is the wrong way? The wrong way is to compare String using the == operator. It is one area in which almost every Java programmer has made mistakes sometimes by comparing two String variables using the == operator. 

How to parse String to Date in Java using JodaTime Example

In this Java tutorial, we will learn how to parse String to Date using Joda-Time library, for example, we will convert date String "04-12-2014" to java.util.Date object which represents this date. Before Java 8 introduced its new Date and Time API,  Joda was only reliable, safe and easy way to deal with date and time intricacies in Java. Java's own Date and Time was not that great, starting from JDK 1.1 when they made java.util.Date a mutable object and when they introduced Calendar in Java 1.2. It is one of the most criticized feature of Java on communities along with checked exception and object cloning

Tuesday, August 15, 2023

How to Accept and Produce JSON as a response in Spring Boot? Example Tutorial

Hello everyone, welcome to the blog post. In this short tutorial, we are going to take an in-depth look at how to consume and produce JSON responses using a widely appreciated Java framework i.e. Spring Boot. As we all know Spring Boot is a framework designed to build a secure web application, microservice, REST API, and production-ready spring application. Modern-day application deals in a large amount of data, which they share in JSON format. A JSON is a standard plain text-based representation of structured data. It is one of the popular formats for data transmission over the internet. Due to its user-friendly syntax and lightweight, it helps in the process faster. 

Saturday, August 12, 2023

How to configure multiple data sources in Spring Boot? Example Tutorial

Spring Boot is a popular framework for building Java applications that simplifies the development process. In some scenarios, you may need to work with multiple databases or data sources in your Spring Boot application. Earlier, we have seen how to change port of spring boot application and in this article will guide you through the process of configuring and using two data sources in Spring Boot. We will explore various approaches and provide practical examples to help you effectively manage multiple data sources in your application.

How to Solve "Error starting Application Context" in Spring Framework?

 Hello guys, Spring Boot is a popular framework for building Java applications, providing a streamlined development experience. However, like any software, Spring Boot applications can encounter errors during startup. One common error that developers may encounter is the "Error starting ApplicationContext" error. This error typically indicates an issue with the application's configuration or dependencies but it's really hard to find what exactly is wrong and how to fix it. In the past, I have shared tips on how to fix error creating bean error and In this article, we will explore various solutions to fix this error and ensure a successful startup of your Spring Boot application.

Wednesday, August 9, 2023

Difference between @RequestParam and @PathVariable in Spring MVC

Hello guys, if you are wondering what is difference between @ReqestParam and @PathVaraible annotation in Spring MVC, most likely because it was asked to you on a Java and Spring interview or maybe you are just curious then you have come to the right place. In the past, I have talked about difference between @Component, @Service, @Reposistory and @Controller annotations and in this comprehensive article we are going to take an in-depth look at the difference between the two most frequently used annotations in Spring MVC. It provides two commonly used annotations, namely @RequestParam and @PathVariable, which play a significant role in parameter handling within web applications. 

Top18 Spring Cloud Features for Microservices Architecture in Java

Hello guys, If you are doing Java development using Spring Boot then you may already know that Spring Cloud is a popular open-source framework for implementing microservices in Java. It provides a wide range of features that simplify the development, deployment, and management of Microservices in Java. In this article, we will discuss some of the key features of the Spring Cloud framework that makes it an excellent framework for developing Microservices in Java. Microservices architecture is a modern approach to building complex applications as a collection of loosely coupled, independently deployable services. 

Tuesday, August 8, 2023

How to create a Microservice in Java using gRPC? Example Tutorial

Hello guys, if you are wondering how to create Microservices in Java then you have come to the right place. Microservices architecture has gained significant popularity due to its scalability, modularity, and ease of deployment. When it comes to building microservices, gRPC (Google Remote Procedure Call) is an excellent choice for facilitating communication between services. In last few articles, I have shared how to build Microservices in Java using Spring Boot and How to build Microservices app using Quarkus and In this article, we will explore how to create a microservice application using gRPC in Java, along with a comprehensive step-by-step tutorial.

Sunday, August 6, 2023

How to Create a Microservice using Quarkus in Java? Example Tutorial

Hello guys, Microservices architecture has become increasingly popular due to its flexibility, scalability, and ease of maintenance. When it comes to building microservices in Java, Quarkus is an excellent framework that provides a lightweight, fast, and efficient runtime. In this tutorial, we will explore how to create a microservice application using Quarkus in Java, along with a comprehensive step-by-step example. In last few articles, we have seen how to create Microservices using Spring Boot and Microservices using gRPC and in this article, we are going to see how to create a Microservice architecture using Quarkus framework. 

What is Service Discovery in Microservices? Client Side vs Server Side Service Discovery?

Hello guys, if you are wondering how different services communicate with each other in a Microservice architecture then you are not alone. Many Java programmer I have interviewed doesn't really know how different services in a Microservice architecture communicate with each other. n the past, I have shared several Microservices design patterns like  Event Sourcing, SAGA, Database Per Microservices, CQRS, API Gateway, Aggregator Design Pattern,  as well as best practices to design Microservices and in this article, I will talk about Service Discovery Pattern. In a distributed system architecture, Service Discovery plays a crucial role in enabling efficient communication between services. Service discovery patterns provide mechanisms for dynamically locating and accessing services within a network. 

Friday, August 4, 2023

What is Backend for front-end pattern in Microservices? How to use it? Example Tutorial

Hello guys, as Organizations embrace Microservices architecture, the need for efficient communication and collaboration between front-end and back-end teams becomes crucial. To address this, the Backend for Front-End (BFF) pattern has emerged as a valuable approach. BFF pattern allows front-end developers to have dedicated back-end services that cater specifically to their needs, enabling them to build user interfaces more effectively.  In the past, I have shared several Microservices design patterns like  Event Sourcing, SAGA, Database Per Microservices, CQRS, API Gateway, Aggregator Design Pattern,  and also shared best practices to design Microservices and in this article, I am going to talk about the Backend for Front-End pattern entails and how to effectively utilize it in microservices architecture.

How to use Deque Data Structure in Java? Example Tutorial

Hello friends, I am really glad to see you all again here. And I know you are here to learn new and valuable Java concepts and continue your journey on Java. Today we are gonna learn something that is really important logically. yes! you heard right, we are going to learn about Deque data structure in Java and how to use Deque in the Java program. Deque is a special data structure, a double-ended queue that allows you to process elements at both ends, I mean you can add and remove objects from both front and rear end. It's a short form of Double-Ended Queue and pronounced as "Deck".  

How to log messages to File and Console in Java using Log4j? Example Tutorial

Hello guys, if you are wondering how to use a logging library like Log4j or SLF4j in Java then you have come to the right place. In this tutorial, you will learn how to implement logging in your Java program using the Log4j library. Log4j is a Java based open source library from Apache Software Foundation, which is widely used for logging messages in Java applications. In order to use log4j in your application, you first need to download log4j.jar files from https://logging.apache.org/log4j/2.x/download.html site. You can download either the zip version or the tar version depending upon whether you are running your Java program in UNIX or Windows. If you are using Maven then you can also add the following dependency in your pom.xml file and Maven will take care of downloading JAR files. 

Thursday, August 3, 2023

Differences between OAuth 2.0 and JWT (JSON Web Token)

Hello guys, both OAuth 2.0 and JWT (JSON Web Tokens) are two widely used authentication and authorization protocols in modern web applications. While both serve similar purposes, there are some key differences between the two that are important to understand, which we will see in this article. This is also an important interview question and if you are preparing for Java and Microservices developer interviews, it's better to know how this two technology works and what are the key differences between then.  In short, OAuth 2.0 is primarily used for authorization, whereas JWT is primarily used for authentication. OAuth 2.0 uses access tokens, whereas JWT is a self-contained token. OAuth 2.0 has a complex authorization flow, whereas JWT has a simple flow. OAuth 2.0 provides better security as it reduces the risk of unauthorized access to protected resources, while JWT can be intercepted if not properly secured. OAuth 2.0 access tokens are short-lived and need to be refreshed periodically, whereas JWTs do not expire.