Since my project has multiple environments and multiple small project groups, I need to handle the corresponding business logic according to different property names, but I can't find any parameter in bootstrap.yml that can set the custom configuration file path.
After I googled, I only found a way to modify the path of the custom configuration file through the startup class
Is there any other better way for me to configure it? Please help me!
Spring Boot look for your externalized configuration file in four predetermined locations:
in classpath root,
in the package /config in classpath,
in the current directory
in /config subdirectory of the current directory.
i think you want to load configuration file from /config folder.
You can programmatically tell Spring Boot to load your configuration files from custom location as below:
ConfigurableApplicationContext applicationContext = new SpringApplicationBuilder(Application.class)
.properties("spring.config.name:application,conf",
"spring.config.location:classpath:/your/location/of/config/folder,classpath:/another/location/of/congig/folder")
.build().run(args);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.