I am using Spring profiles to load the configuration file based on spring.profiles.active
<beans profile="local">
<bean id="configurationFile" class="org.springframework.core.io.ClassPathResource">
<constructor-arg value="META-INF/local.yml" />
</bean>
</beans>
<beans profile="production">
<bean id="configurationFile" class="org.springframework.core.io.ClassPathResource">
<constructor-arg value="META-INF/production.yml" />
</bean>
</beans>
And then I am auto wiring
@Autowired
public Configs(ClassPathResource configurationFile) throws IOException {
super(configurationFile, MyConfiguration.class);
}
This is working fine at runtime, but I am getting compiler errors that multiple beans are found as defined in my xml above, how can I overcome this check ?