Spring boot multiple configuration files loading, unified loading

preparing to migrate from spring mvc to spring-boot technology stack, there is a doubt about multiple configuration files. In the process of looking at it, I found that the configuration of spring boot is a great advantage, but I didn"t really realize the advantages.

if you have multiple (> 6) properties files, most of them are about the configuration of upstream and downstream addresses, database configuration, and some default variables. But to see spring-boot, you need to have a configuration class for each configuration file, then declare configuration variables in it, and then use the @ Value annotation.

question:
is there a better way to uniformly load all configuration file variables into the spring container and use them directly without having to write multiple configuration bean?

thx

Mar.29,2021

Yes, you need several annotations. The variables of the corresponding configuration type are promoted to the Config, of a class as follows

  

your requirement should divide the configuration into multiple profile, and activate the corresponding profile in different environments.

Menu