I have a bean called SpringUtil, which is
@Component
public class SpringContextUtil implements ApplicationContextAware {
private static ApplicationContext context = null;
@Override
public void setApplicationContext(ApplicationContext applicationContext)
throws BeansException {
this.context = applicationContext;
}
public static <T> T getBean(String beanName) {
return (T) context.getBean(beanName);
}
...
}
There is another bean which uses SpringUtil in its init method, so it requires that SpringUtil to be loaded as bean before it. I tried @ConditionalOnBean(SpringUtil.class) but it doesn't work. Are there any workaround? or radically, make SpringUtil to be initialized before all other beans.