0

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 ?

Novice User
  • 3,552
  • 6
  • 31
  • 56

0 Answers0