Using Bean Configuration in Spring Boot
In our previous articles, we have seen in detail about Dependency Injection in Spring Boot and how we register a class for dependency injection in a Spring Boot application.
We have previously seen in detail about Dependency Injection in Spring Boot and how we register a class for dependency injection in a Spring Boot application.
We have seen that to register a Class into Spring Dependency Injection, we need to first mark the class as Component or any derivatives of the Component annotation.
But sometimes we may wish to register the objects of any 3rd party Libraries which are not local to our application. Examples such as Database Connections, Rest Clients, Kafka Connections, AWS Cloud Clients etc.
These are libraries which are outside of our application and may not have been marked Components or anything related to spring. We don't even be able to modify their source code because these are external libraries included into the application via Jar files.
How do we make Spring Container take care of the object management for such libraries which are outside to our application but are used in our code?
We use Configuration Beans.
In this week's newsletter, let me introduce to you what are configuration beans and how do we inject 3rd party library objects into spring injection system.
Full the article here - https://referbruv.com/blog/how-to-use-bean-configuration-in-spring-boot-with-an-example/