Category: Java


  • Spring boot change default port of server

    By default, Spring boot applications start with embedded tomcat server start on default port 8080. We can change default server port to any other port, using any one of below technique. 1. Update default spring boot server port from application properties file We can do parcels of brilliant things by basically making few passages in application properties record in any spring boot application. Changing server port is one…

  • Conquering Concurrency: Pessimistic Locking in Spring Boot

    In the bustling world of multi-user applications, ensuring data integrity becomes paramount. When multiple users contend for the same resource, conflicts can arise, leading to lost updates and unintended side effects. Here’s where pessimistic locking steps in, acting as a valiant knight guarding data consistency in Spring Boot applications. What is Pessimistic Locking? Imagine two…

  • Mastering Spring Boot: Unleashing the Power of Productivity

      In the world of Java development, Spring Boot has emerged as a game-changer. This revolutionary framework provides a streamlined way to build production-ready applications. With its minimalist approach and a plethora of built-in features, Spring Boot has become the go-to choice for developers seeking rapid application development. The Spring Boot Advantage Convention over Configuration…

  • How to find out the differences between 2 objects in Java (2023)

    [web_stories title=”true” excerpt=”false” author=”false” date=”false” archive_link=”true” archive_link_label=”” circle_size=”150″ sharp_corners=”false” image_alignment=”left” number_of_columns=”1″ number_of_stories=”5″ order=”DESC” orderby=”post_title” view=”circles” /] In this post, we will showcase a step-by-step guide on how to detect and present distinctions between two java objects by leveraging a set of classes and interfaces provided by Apache Commons Lang. Classes, Interfaces, and pom.xml The classes…

  • @PropertySource vs @PropertySources 2 Annotations Overview (2023)

    @PropertySource and @PropertySources Annotations In Spring Framework, the @PropertySource annotation is used to specify the source of external property files that contain key-value pairs. These properties can be injected into Spring beans using the @Value annotation or by using the Environment object. Here’s an example of how to use @PropertySource in a Spring application: Create…

  • Exploring Bounded and Unbounded Generic Types in Java

    Introduction: Generic types in Java provide a powerful mechanism for creating reusable and type-safe code. They allow developers to create classes, interfaces, and methods that can work with different data types while maintaining compile-time type safety. Java offers two fundamental categories of generic types: bounded and unbounded. In this article, we will understand the concepts…

  • Difference between YYYY vs yyyy -Java Date Formatter

    Intro Dates in programming are hard. The ISO-8601 Date standard made them easier, but to be entirely honest I’m not ISO-8601 Certified, so I’m not very good at my job. What I do know though is the very important difference between YYYY and yyyy when formatting dates. The Difference between yyyy and YYYY According to the DateTimeFormatter Java…

  • How to Cancel a Task in Java ExecutorService

    Learn to cancel a task submitted to an executor service if the task still has to be executed and/or has not been completed yet. We can use the cancel() method of Future object that allows making the cancellation requests. 1. Future cancel() API The Future.cancel() method takes one argument of type boolean. boolean cancel(boolean mayInterruptIfRunning); Depending on the value of mayInterruptIfRunning and the status of the task submitted…

  • Java – Waiting for Running Threads to Finish

    Java concurrency allows running multiple sub-tasks of a task in separate threads. Sometimes, it is necessary to wait until all the threads have finished their execution. In this tutorial, we will learn a few ways to make the current thread wait for the other threads to finish. 1. Using ExecutorService and Future.get() Java ExecutorService (or ThreadPoolExecutor) helps execute Runnable or Callable tasks asynchronously. Its submit() method returns a Future object…

  • ExecutorService invokeAny()

    Learn to use ExecutorService.invokeAny(tasks) method where we execute multiple tasks at the same time, but we make a decision when any one of those tasks is completed and return its result. 1. invokeAny() method This method executes the given list of tasks, returning the result of one that has completed successfully (i.e., without throwing an exception),…