In this post under Spring Core, I will explain with example how to wire two beans annotated with @Bean annotation using setter methods. For our example lets take the below two classes. Bean1 package package12; public class Bean1 { private Bean2 bean2; public Bean1() { } public void setBean2(Bean2 bean2) { this.bean2 = bean2; }…… Continue reading Wiring together @Bean annotated beans using setter approach
Month: November 2023
Configuring Recovery Callback (using interceptor)
In this post under Spring Retry –> XML Configuration –> Spring AOP, I will show with example how to configure RecoveryCallback using Spring AOP. For our example we will create a recovery class as shown below CustomMethodInvocationRecoverer package defaultPackage; import org.springframework.retry.interceptor.MethodInvocationRecoverer; public class CustomMethodInvocationRecoverer implements MethodInvocationRecoverer<Void> { @Override public Void recover(Object[] args, Throwable cause) {…… Continue reading Configuring Recovery Callback (using interceptor)
Changing scopes of @Bean annotated beans
In this post under Spring Core, I will explain with example how to change scopes of Spring beans annotated with “@Bean” annotation. By default the “@Bean” annotated beans have singleton scope. Which means that whenever a dependee bean asks for a reference to dependent bean and the dependent bean scope is “singleton” then Spring makes…… Continue reading Changing scopes of @Bean annotated beans
Loading environment properties from custom .env file
In all my previous post under DotEnv, I showed how to load environment properties from a file named “.env”. The “.env” file can be present in the project directory or in some other directory. By default, DotEnv is configured to search under project directory. In one of my previous posts, I showed how to change…… Continue reading Loading environment properties from custom .env file
Wiring together @Bean annotated beans using constructor approach
In this post under Spring Core, I will explain with example how to wire two beans annotabed with @Bean annotation using constructor. For our example lets take the below two bean classes. Bean1 package package10; public class Bean1 { private Bean2 bean2; public Bean1(Bean2 bean2) { System.out.println(“Hello its Bean1”); this.bean2 = bean2; } } As…… Continue reading Wiring together @Bean annotated beans using constructor approach