我有一个自动配置类SFConfig,它定义了以下bean
@Bean
@ConditionalOnBean(value = SalesforceClientConfig.class)
SalesforceClient sfClient(SalesforceClientConfig sfConfig){
return SalesforceRestClient.from(sfConfig);
}
@Bean
//@ConditionalOnBean(value = Authentication.class)
SalesforceClientConfig sfClientConfig(Authentication sfAuthentication){
return DefaultSalesforceClientConfig.builder()
.authentication(sfAuthentication)
.mapper(mapper())
.build();
}显然,因为创建了SalesforceClientConfig,所以应该创建sfClient bean。但它抛出了一个异常:
Bean method 'sfClient' in 'SFConfig' not loaded because @ConditionalOnBean (types: com.ondeck.salesforceclient.SalesforceClientConfig; SearchStrategy: all) did not find any beans这很奇怪,因为这是一个自动配置类,它应该找到那个bean。有什么想法吗?
下面是我在文件中定义自动配置类的方式:
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\com.ondeck.letter.config.SpringJpaDBConfig,\ com.ondeck.letter.config.SFConfig
发布于 2017-03-02 04:17:33
根据Annotation Type ConditionalOnBean的说法,建议在用@EnableAutoConfiguration注释的自动配置类中使用@ConditionalOnBean注释。
因此,您可能没有正确定义自动配置类。
https://stackoverflow.com/questions/42540278
复制相似问题