I am making a Java library with Spring cloud config server support, which provides different ways to get application properties from different sources depending on feature flags (input environment properties). For example, AWS S3 bucket will be searched for property files by an application on startup if a feature flag is enabled.
As for now when I add my library in my application it works fine if I add spring profile "awss3" and I see there is some logic on this profile in EnvironmentRepositoryConfiguration class, but when I remove this profile, it starts trying to instantiate DefaultRepositoryConfiguration and expectedly fails.
I've tried to define my configuration class with awss3 repository bean creation
Код: Выделить всё
@Configuration
@ConditionalOnProperty(name = "aws.s3.enabled", havingValue = "true")
public class S3Configuration {
@Bean
public AwsS3EnvironmentRepository awsS3EnvironmentRepository(AwsS3EnvironmentRepositoryFactory factory,
AwsS3EnvironmentProperties environmentProperties) {
return factory.build(environmentProperties);
}
}
I tried to manipulate ordering using annotations like Order and AutoConfigureBefore, and I tried to remove my configuration file from Autoconfiguration. import file in properties so it's not interpreted like autoconfiguration, but it does not help.
My aim is just to escape setting up a profile and depending only on feature flags when using AWS S3 as a config server, maybe someone has a clue how could I achieve this?
Источник: https://stackoverflow.com/questions/781 ... g-profiles