I have a microservice where I want to have few properties which are environment dependent so I'm using application.yml, and application-dev.yml, application-int.yml etc.....
upon startup I pass spring.profiles.active=myprofile
and relevant applicaiton-myprofile.yml
gets loaded along with applicaiton.yml
. So far everything works fine.
But now I want to categorize some of my non-environment-specific properties into their own business-modules, so ALONG WITH my application.yml applicaiton-.yml I also want to load properties from few more yml files into spring ENVIRONMENT
. so I could be able to create create correct BusinessConfigProperties class with @ConfigurationProperties
.
To achieve this I tried to add those yml file names in spring.config.location as below
spring:
config:
name:
- some-props
- very-different-name-props
location:
- classpath:/config/*
I've provided config name too, and all my yml files are present in /config folder
But I'm still unable to read any of the properties mentioned in these file.
I can overcome this by manually loading files with org.yaml.snakeyaml.Yml
abut that is too much boilerplate code to read YML map and instantiate my classes. There should be an easy way do achieve this with spring.
UPDATE
I updated above to,
spring:
config:
location:
- classpath:classpath:/config/some-props.yml,classpath:/config/very-different-name-props.yml
But this also isn't working
I'm not using profile, because along with above files, I already have applicaiton-<profile>.yml
for environment specific properties. And I will be passig spring.profile.active
as environment name in startup jvm arguments.
Also I don't want to name these files starting with application-<added_profile>.yml