How to alias a bean outside the bean definition using Java config in Spring Boot?
I have this as well, and solved it like this:
@Component
public class AliasConfiguration implements BeanFactoryPostProcessor {
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
beanFactory.registerAlias("originalBeanName", "newAlias");
beanFactory.registerAlias("originalBeanName", "newAlias2");
beanFactory.registerAlias("otherOriginalBeanName", "newAlias3");
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With