Category: fullstackdevelopment

  • How to implement authorization using JWT/OAuth2 in Spring Boot?

    There are two main aspects in Security: Authentication deals with whether the user who tries to access an application is a legitimate user. Authorization deals with whether the user has rights to read/modify a particular resource in the application. In this post let us look into authorization in Spring Boot. Let us consider an application…

  • How to protect REST API using Basic Authentication?

    How to protect REST API using Basic Authentication?

    REST APIs are one of the primary means of communication between different apps in modern web applications. Anyone can send a request to a public REST API and get a response. This poses security risk. We need only legitimate users to hit our REST APIs and get the information they need. We can do this…

  • How to create a REST API in Spring Boot?

    How to create a REST API in Spring Boot?

    Let’s say you want to create an ecommerce store. And you want to expose REST APIs to the end users to do CRUD(Create, Read , Update and Delete) operations on your store items. You can do this with minimal effort in Spring Boot. Let’s create the REST APIs. Creating a REST API in Spring Boot…

  • Java 21 – Scoped Values

    How do you pass a value from one part of your code to another. Let’s say from one class to another. By using method arguments. Is there any other way that you can access a shared variable? For example, Let’s say you need to pass the user name who logged into your web app from…

  • How to connect to database using ConnectionDetails interface in Spring Boot?

    Let’s say you want to connect to a database in your Spring Boot application. You first add Spring Data dependency. Then to configure the database details , you had two options: Starting Spring Boot 3.1.1 you have one more option. Using ConnectionDetails interface. Let’s see how to do that with an example. STEP 1: Add…

  • Java 21 – Structured Concurrency

    Let’s say you want to perform a group of tasks in Java. And all these tasks are part of a single unit of work. And all these tasks can be executed independently. How can this be done in Java? You can execute each task sequentially. So you execute task 1 , then task 2 and…

  • Java 21 – Virtual Threads

    Java supports concurrency. You can perform multiple tasks at the same time in a program. And how does Java implement this? Using Threads! A thread is the basic unit of concurrency in Java. If you want to perform multiple tasks in parallel you create one thread for each task and perform them in parallel. And…

  • Java 21 – Sequenced Collections

    How do you get the last element of a list in Java? Using a code similar to below: That doesn’t look elegant! And how do you get the last element for a Sorted Set? That looks much more elegant but then different collections are having different ways to get the last element. There is no…

  • Java 21 – String templates

    Contents: The Problem “String” is a basic and widely used data type in any programming language. Most of the data we deal with are texts which are represented by String datatype. One of the operations we often do on text is replacing part of the text with dynamic values . This is called interpolation. Languages…

  • How to implement Circuit Breaker Design Pattern in Spring Boot?

    How to implement Circuit Breaker Design Pattern in Spring Boot?

    Table of Contents: Problem: Fault tolerance is a major requirement for enterprise applications. If your application gets huge load , how does it behave? If something wrong happens within your application and you still want to handle it gracefully , what do you do? Fault tolerance is especially important for microservices since many microservices communicate…