Author: Vijay SRJ

  • How to set up AWS access credentials in your local ?

    If you want to access AWS resources from your local machine using AWS SDK , you can’t do it by default. You need to configure AWS access key id and AWS secret access key in your local. You can do this using AWS cli. Here is how to do it: STEP1: Install AWS cli You…

  • How to schedule tasks in Spring Boot?

    Let’s say you want to schedule background tasks in your application , may be every ten minutes or at a fixed time every day or during weekends. How do you do that in Spring Boot? Spring Boot provides a simple and straightforward solution: By just using @Scheduled annotation. Here are the steps in detail: STEP1:…

  • Rest API vs HTTP API – Are your REST APIs really REST APIs?

    Let’s say you want to create a REST API using a framework like Spring Boot. You create a class annotated with @RestController. And then you create APIs using @RequestMapping/@GetMapping/@PostMapping annotation. Are these really REST APIs? No. They are just HTTP APIs. What is the difference between the two? HTTP is one of the ways information…

  • How to read a JSON request inside a Spring Boot filter?

    Let’s say you are using a filter in your spring boot application. Spring boot (Spring Security) already internally uses many filters to filter requests coming to your application. If you are going to create a custom filter you can do so by implementing Filter interface from javax servlet package or by extending GenericFilterBean/ OncePerRequestFilter provided…

  • How to consume a large response using Spring WebClient?

    Spring WebClient is a new library provided by Spring to call REST services. It can be used to call rest services in an asynchronous way. Spring team is planning to retire RestTemplate and so it is better to start using Spring WebClients in your projects even for synchronous calls. And if you do use Spring…

  • How to write a generic REST client in Spring Boot?

    We live in the world of microservices. REST APIs are all over and they communicate with each other. To communicate with each other in the Spring World , they use RestTemplate or Spring WebClient or Java’s own HttpClient(Java 11) or any other third party libraries. We call them REST clients. It will be nice if…

  • What is @MapsId used for in JPA/Hibernate? – Part II

    In the previous post , we saw how and why to use @MapsId in a One to One relationship. In this post , lets see how it comes handy in a One to Many relationship. Let’s take the same Musician entity as the parent object. Let’s take an Album entity as the child object. A…

  • What is @MapsId used for in JPA/hibernate? – Part 1

    @MapsId annotation. If you ever wondered what this annotation is for , here is an in depth analysis of it: When is this annotation used? It is used if the primary key of a child table is the same as the primary key of a parent table Why is this used? By specifying the annotation…

  • Java 17 features every Java developer should know

    Java 17 released today ( 14 September 2021). Though there are around 14 new features introduced in this release , only two of them directly help developers and they should be aware of these. Those two are : Pattern Matching for Switch Sealed Classess Pattern Matching for Switch is introduced as a preview feature and…

  • Java 21 – Pattern Matching for Switch

    Switch statement in java has gone through a rapid evolution since Java 7. You could compare only integers until Java 7. And then Java 8 allowed you to compare strings and enums as well. And then Java 12 introduced a flurry of new features: Java 13 later introduced yield keyword to be used instead of…