Home > Enterprise >  not able to get the bean which is created in another 3rd party spring boot lib
not able to get the bean which is created in another 3rd party spring boot lib

Time:11-09

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.

CodePudding user response:

This is information is not enough, can you please share your pom file of library that contains CustomObject.

I need to see pom file build section code.

CodePudding user response:

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.

  • Related