-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
现有场景如下
class Configuration1 implements ApplicationContextAware {
@Bean
@ConditionalOnBean(Interface1.class)
Service1 service1(Interface1 interface1) {
return new Service1(interface1);
}
@Bean
Service2 service2() {
Service1 service1 = applicationContext.getBeansOfType(Service1.class);
return new Service2(service1);
}
// TODO about save applicationContext
}
@Configuration
@Import(Configuration1.class)
class AutoConfiguration1 {
}
@Import(Interface1Impl1.class)
@interface EnableInterface1Impl1 {
}
@SpringBootApplication
@ComponentScan("<current pkg>")
@EnableInterface1Impl1
class A {
public static void main(String[] args) {
SpringApplication.run(A.class, args);
}
}最终启动时,service2 的示例找不到 service1 的示例。也就是这种情况下,@ConditionalOnBean 的判断为 false。最终启动失败
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels