Issue
I have a spring boot app in which I have added another library (in pom.xml).
This library is also a spring boot library which has created some beans and made the beans available using @Bean. The code snippet in 3rd party library is like this :
@Bean
public CustomObject customObject() {
return new CustomObject();
}
Now, I am using this library in my application, but I dont see this bean registered with my application. I checked all the beans registered with application Context and also tried loading from application context. But no luck.
What am I missing here? The purpose of this 3rd party library is to check some config and create this bean, so if I have to manually create this bean, it takes away the whole purpose.
Solution
as suggested by @Rohit in comments, I missed to add the package of the class in the 3rd party lib jar under component scan. After adding the package under component scan, issue is resolved.
Answered By - Onki
Answer Checked By - Katrina (JavaFixing Volunteer)