Using @Profile on @Beans annotated beans

In the previous post under Spring Core, I showed how to use “@Profile” annotation with “@Configuration” annotation. In this post under Spring Core, I will show with example how to use “@Profile” annotation with “@Bean” annotation. In previous post I also mentioned that “@Profile” annotation can be used with “@Configuration”, “@Bean”, and “@Component” annotation. The…… Continue reading Using @Profile on @Beans annotated beans

Creating a custom serializer or deserializer

In this post under GSon, I will explain with example how to create custom serializer and deserializer and configure Gson object to use it. For our example lets take the below JavaBean Class structure. Student package defaultPackage;import java.util.Date;public class Student { private int id; private String name; private Integer rollnum; private Date date; public int…… Continue reading Creating a custom serializer or deserializer

Serialize and DeSerialize Generic classes

In this post under Gson, I will show with example how to serialize and deserialize generic classes. Below is the complete code for your reference Main class 1 package defaultPackage;2 3 import com.google.gson.Gson;4 import com.google.gson.reflect.TypeToken;5 6 import java.lang.reflect.Type;7 import java.util.ArrayList;8 import java.util.List;9 10 public class GsonDemo16 {11 public static void main(String[] args) {12 List<String> actors…… Continue reading Serialize and DeSerialize Generic classes

Using @Profile with @Configuration classes

In this post under Spring Core, I will show with example how to use “@Profile” annotation for “@Configuration” annotated classes. In the real world scenario, whenever we develop an application, we develop with a goal that it should perform according to agreed functional requirements, regardless of whether the application is running in production or testing…… Continue reading Using @Profile with @Configuration classes

Verifying password is of specified length

In this post under Passay, I will show with example how to verify that the password is of specified length. Below is the complete code for your reference Main class 1 package defaultPackage;2 3 import org.passay.LengthRule;4 import org.passay.PasswordData;5 import org.passay.PasswordValidator;6 import org.passay.Rule;7 import org.passay.RuleResult;8 9 public class Example3 {10 public static void main(String[] args) {11…… Continue reading Verifying password is of specified length

Displaying meaningful error messages when password validation fails

In this post under Passay, I will show with example how to display error messages for failed password validation. Below is the complete code for your reference. Main class 1 package defaultPackage;2 3 import java.util.List;4 import java.util.Scanner;5 6 import org.passay.LengthRule;7 import org.passay.PasswordData;8 import org.passay.PasswordValidator;9 import org.passay.Rule;10 import org.passay.RuleResult;11 12 public class Example2 {13 public static…… Continue reading Displaying meaningful error messages when password validation fails

Verifying password length is within specified min and max length

In this post under Passay, I will show with example how to verify whether a user entered password is within the configured length. Below is the complete main code for your reference. Main code 1 package defaultPackage;2 3 import java.util.Scanner;4 5 import org.passay.LengthRule;6 import org.passay.PasswordData;7 import org.passay.PasswordValidator;8 import org.passay.Rule;9 import org.passay.RuleResult;10 11 public class Example1…… Continue reading Verifying password length is within specified min and max length

WebClient.Builder example

In this post under Spring WebClient, I will explain with example the purpose and how to use “WebClient.Builder” class In all my previous post under Spring WebClient, whenever I need to create an instance of WebClient, I used the below approach WebClient webClient = WebClient.create(“https://jsonplaceholder.typicode.com&#8221;); This created an instance of “WebClient” class with default configurations…… Continue reading WebClient.Builder example

@SerializedName annotation example

In this post under Gson, I will explain with example the purpose of “@SerializedName” annotation. By default when we serialize an object to Json, the class field names are used as key names in the Json. For example if we have the below class structure JavaBean class structure package defaultPackage;import com.google.gson.annotations.SerializedName;import java.util.List;public class Author {…… Continue reading @SerializedName annotation example