'loading datasource config from AWS S3 thru archaius in SpringBoot 2.1.1.RELEASE

My springBoot app loads datasource correctly from application.properties/yml in classpath but I want to externalize datasource config so I have been trying to use archaius to load PolledConfigurationSource from S3 with following code

I have multiple datasources to connect.

PolledConfigurationSource source = new S3ConfigurationSource(s3Client , bucketName, PROPERTYFILE);
DynamicConfiguration configuration = new DynamicConfiguration(source, 
new FixedDelayPollingScheduler(100, 60000 ,true));
ConfigurationManager.install(configuration);

I do have config class annotated with @Configuration as well as below class.

Here is how I m creating Datasource / JDBCTemplate

@Bean(name="datasource-1")
@ConfigurationProperties(prefix="spring.datasource.datasource-1")
public Datasource initializeDatasource1(){return DatasourceBuilder.create().build(); }

@Bean(name="datasource-2")
@ConfigurationProperties(prefix="spring.datasource.datasource-2")
public Datasource initializeDatasource2(){return DatasourceBuilder.create().build(); }

Loading archaius with SpringBoot 1.x.x was not a problem before but with SpringBoot 2.x.x plus a few dependencies from spring cloud , it doesn't work and I get exception for "jdbcUrl / url" not defined if I move config from application.properties.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source