I want to disallow bean definition overriding in a SpringApplication
. In other words, I want the effect of invoking GenericApplicationContext.setAllowBean
I have come across similar issue but not in spring boot application but in normal spring-mvc application which is having xml based configurations, so this solution might help people looking for other than spring-boot apps,
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
beanFactory.setAllowBeanDefinitionOverriding(false);
new XmlBeanDefinitionReader(beanFactory).loadBeanDefinitions(new ClassPathResource("spring-first.xml"));