Reputation: 7647
In my spring boot project i have to use a external library which it has define beans in spring context. So in my Application class i have add below which are the base package for bothe my project and the external library,
@SpringBootApplication(exclude = SecurityAutoConfiguration.class)
@EnableHypermediaSupport(type = { EnableHypermediaSupport.HypermediaType.HAL })
@EnableSwagger2
@ComponentScan(basePackages = {"com.mylibrary.test", "com.otherlibrary.springtool"})
//@EnableDiscoveryClient
public class Application extends RepositoryRestMvcConfiguration {
}
But the beans in other library such as @Configuration are not initialize?
Upvotes: 7
Views: 10407
Reputation: 1403
I had something similar when I was trying to use open feign interfaces coming from an external lib and then I had to add the @EnableFeignClients(basePackages = {"lib.pckg"})
, because the Feign had to create the beans for me, not the Spring IoC.
It would be good if you provide some log error.
Upvotes: 1
Reputation: 192
@ComponentScan works for the classes that are annotated with @Component, @Repository or @Service. Make sure classes in "com.otherlibrary.springtool" are annotated with above annotation to be found or else you have to declare them as Spring beans with @Bean annotation. Hope it helps.
Upvotes: 2