In Spring Boot, I know that I can replace application.properties with application.yml and use the YAML format. However, my application.yml is getting crowded so I need to split it up a bit. How can I do that? I would like to do something like this:
... @Configuration @EnableAutoConfiguration @EnableWebMvc @EnableScheduling @PropertySource({"classpath:application.yml", "classpath:scheduling.yml"}) public class ApplicationConfig { ...
You can use spring. config. location to specify paths to additional config files as a comma separated list.
To add different files you can use the spring. config. location properties which takes a comma separated list of property files or file location (directories). The one above will add a directory which will be consulted for application.
Spring Boot supports different properties based on the Spring active profile. For example, we can keep two separate files for development and production to run the Spring Boot application.
@PropertySource
annotation, you not need itscheduling.yml
into src/main/resources/application-scheduling.yml
add in src/main/resources/application.yml
file next line:
spring.profiles.include: 'scheduling'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With