В одном из наших spring-boot
сервисов мы имеем следующую ситуацию.У нас есть два класса конфигурации
@Configuration
public class Foo{
@Bean
public RabbitTemplate rabbitTemplate(ConnectionFactory connectionFactory, MessageConverter messageConverter) {
log.debug("Initializing rabbitTemplate for sending messages to: {}", rabbitProperties.getHost());
RabbitTemplate template = new RabbitTemplate(connectionFactory);
template.setMessageConverter(messageConverter);
return template;
}
}
@Configuration
public class Bar extends Foo{
// Something else in here, but nothing with same method name or return type like in parent
}
Теперь мы получаем BeanDefinitionOverrideException
, более или менее говорящий, что Бин переопределен, и я полностью понимаю, почему.Я также теперь, что вы можете установить свойство spring.main.allow-bean-definition-overriding=true
, но мне было бы интересно, если есть другие умные решения, так как я, в этом случае, даже не переопределить его в дочернем классе.