I'm using ConfigurationProperties annotation to map some values from application.yml to java class. Everything works fine when using it with localhost config file, but when I'm fetching configurations from cloud config, those values cannot be found. I guess that problem may be that configuration file name may be different depending on which configuration is chosen and spring don't know in which file look for them.
@Configuration
@ConfigurationProperties(prefix = "some.prefix")
public class SomeMappedConfigClass {
private String variable1;
private String variable2;
}
and yaml with configurations
some.prefix:
variable1: abc
variable2: xyz
I was trying to map config file via PropertySource annotation but it expects config file name which in my case may be different.
@PropertySource("classpath:some-application.yml")
Is there any way to pass to PropertySource current loaded config regardless of config file name? Log that I receive after successful configuration fetch from cloud config, for application: web-server profile: LOCAL
Located property source: CompositePropertySource {name='configService', propertySources=[MapPropertySource {name='file:central-config/web-server-LOCAL.yml'}]}