In the previous tutorial, we learned that how we can do User Authentication with Amazon Cognito in Spring Boot Application. In this tutorial, we will take our previous learnings and continue with the following. Create Rest Controller to handle /login HTTP POST requests. Read username and password from the request body to authenticate with Amazon Cognito…
Read More Amazon Cognito User Authentication in Spring Boot REST
In this tutorial, you will learn to design and deploy the multi-container based Spring Boot application using Docker compose. To learn more about Docker, please check Docker Tutorials page. Overview In the previous tutorial, we learned how to Dockerize a simple Spring Boot-based application. As it was a small application we have handled each container…
Read More Docker Compose: Deploying Spring Boot Microservices
In this tutorial, you will learn to design and run in a Docker container a simple Spring Boot application that uses MongoDB. To learn more about Docker, please check Docker Tutorials page. Overview Docker is becoming an increasingly important tool in the DevOps process. It allows you to package an application, along with all its…
Read More Spring Boot Application with MongoDB in Docker Container
In this tutorial, we are going to see how to create a simple Spring Boot project containing a handler that takes the name of the user as a parameter and returns a welcome message. We are then going to deploy it as a serverless application on AWS Lambda and test it. The first step is…
Read More AWS Lambda with Spring Boot – A Simple GreetMe Example
In the previous blog post, we covered the basics of how to use Keycloak with Spring boot. In this blog post, we will explore Role-based Access Control to Rest API with Keycloak. So let’s get started! Imagine we have a microservice for a Research Journal Management System that can serve users with two types of…
Read More Role-Based Access Control to REST API with Keycloak
In this tutorial, you will learn how to use Jackson ObjectMapper with Spring Boot application to serialize and deserialize Java objects. Overview In today’s time, the JSON format is one of the most popular formats to transfer and exchange data on the world wide web. Almost all RESTful web services support JSON as input and output…
Read More Jackson ObjectMapper Tutorial
In this tutorial, we are going to see how we can throw custom exceptions with a custom payload in a Spring Boot application and deploy it on AWS as a serverless Lambda function. Let us start by creating a simple Spring boot project. In this project, we are going to create a Request Handler that…
Read More Handle Custom JAVA Exceptions in AWS Lambda with Spring Boot
class CheckIfArrayContainsValue { public static void main(String[] args) { String[] programmingLanguages = {“Python”, “Kotlin”, “Ruby”, “JavaScript”, “C#”, “Java”, “Flutter”}; for (String lang : programmingLanguages) { if (lang.equals(“Java”)) { System.out.println(“It does contain!”); break; // value found, exit the loop } } } } Output: It does contain! Here, we are iterating over the array, and…
Read More Check if Array Contains a Value in Java
Output: Some String Here, we put the creation of the Scanner object into a try-with-resources because we want to close the Scanner after it reads all the data. We passed the “\\A” to tell the Scanner to read the entire input stream. import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; class ConvertInputStreamToString { /** *…
Read More Convert InputStream to a String in Java
Internationalization (i18n) is the process of making your application and services capable of delivering in different languages. This tutorial will show how the Spring Boot framework manages internationalization. Overview The internet has become global, implying that any application or website can target millions of users worldwide. Although half of the world’s population may have access…
Read More Spring MVC Internationalization Tutorial
<dependency> <groupid>org.apache.poi</groupid> <artifactid>poi-ooxml</artifactid> <version>5.0.0</version> </dependency> If you are not familiar with Maven, you can check out this tutorial: Create Java Project with Maven. import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; @Data @AllArgsConstructor @NoArgsConstructor public class Product { private int id; private String color; private String size; private int cost; private String description; } import org.apache.poi.ss.usermodel.Cell;…
Read More Read and write Excel files in Java
<dependency> <groupid>io.projectreactor</groupid> <artifactid>reactor-test</artifactid> <version>3.1.0.RELEASE</version> <scope>test</scope> </dependency> class ReactiveJavaTutorialTest { @Test public void testFlux() { //Create a Flux Flux <Integer> fluxToTest = Flux.just(1, 2, 3, 4, 5); // Create a test StepVerifier.create(fluxToTest) .expectNext(1) .expectNext(2) .expectNext(3) .expectNext(4) .expectNext(5) .expectComplete() // we expect Flux to complete after sending the number 5 which is the last element .verify(); }…
Read More Testing with StepVerifier in Project Reactor
This is a Java JSON tutorial. Here, you will learn what JSON is and how to work with JSON format in Java. You will see where to find the required JSON libraries and parse Java Objects to JSON and vice versa. Let’s get started. What is JSON? JSON (JavaScript Object Notation) is a lightweight text…
Read More Java JSON tutorial
This tutorial will teach you how to use Keycloak to secure your Spring Boot Application. To find other tutorials, check the Keycloak tutorials page. What is Keycloak? According to Keycloak’s official website, It is an open-source Identity and Access Management solution aimed at modern applications and services. It makes it easy to secure applications and…
Read More A Guide to use Keycloak with Spring Boot
In this tutorial, we are going to see how to handle exceptions from a Lambda function in the API Gateway. For Lambda exceptions, we have to map the error status returned by the Lamba functions to the HTTP Status of the methods in API Gateway. If not, the API Gateway returns a 200 OK status…
Read More Handling Exceptions from AWS Lambda written in JAVA