I have 2 (or more) configuration properties files located in a project, and I want to upload them for different data sources.
I tried to do the following:
@Bean
@ConfigurationProperties(locations = {"#{myconfigroot.getRootFolder()}/datasource1.properties"}
public static DataSource getFirstDatasource() {
return DataSourceBuilder.create().build();
}
But obviously, this will not work because the ConfigurationProperties annotation location property does not go through spEL. (Or maybe I'm writing this incorrectly?) Myconfigroot.getRootFolder () is a static method that returns the path to datasource1.properties.
I ask for advice. Thank.
===== Edited =======
I believe this is a common problem when someone wants their application to want to download various configuration files. For some reason, the location and file name cannot be placed in the startup script or on the command line, or the path can only be determined at run time, which requires spring to load them during the creation of the bean.
I tried using PropertySourcePlaceHolderConfigurer but it doesn't seem to work.
Can anyone share some lights?
source
share