Two beans with the same name results in ConflictingBeanDefinitionException despite using @Primary
I have an application initializer class that is used to insert application specific data to database. @Component("applicationInitializer") public class ApplicationInitializer { @PostConstruct public void init(){ // some clever code here } } There is also DevApplicationInitializer class that is used to initialize database with some sample data on developer machine (this class is excluded when deploying production code). @Component("applicationInitializer") @Primary public class DevApplicationInitializer extends ApplicationInitializer { @PostConstruct @Override public void init(){ super.init();