库源码:com.mzt.logapi.starter.configuration.LogRecordProxyAutoConfiguration
@Bean
@ConditionalOnMissingBean(IOperatorGetService.class)
@Role(BeanDefinition.ROLE_APPLICATION)
public IOperatorGetService operatorGetService() {
return new DefaultOperatorGetServiceImpl();
}
一. 在 spring boot 启动类添加 @EnableLogRecord ,@ConditionalOnMissingBean 有效
@EnableLogRecord(tenant = "temp")
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
二. 在配置类添加 @EnableLogRecord ,@ConditionalOnMissingBean 无效,启动报错
@EnableLogRecord(tenant = "temp")
@Configuration(proxyBeanMethods = false)
public class LogRecordConfiguration {
public LogRecordConfiguration() {
}
/**
* 自定义获取操作人
*/
@Bean
public IOperatorGetService operatorGetService() {
return () -> {
Operator operator = new Operator();
operator.setOperatorId("test");
return operator;
};
}
}
repo: https://github.com/TheLastSunset/spring-boot-ConditionalOnMissingBean-issues.git
public, operator, return, Bean