Documentation says that to use native file backend is necessary to use spring.profiles.active=native
.
But if it's necessary to use different profiles (embedded config server with local files for example) it'd be impossible to change behavior for staging or production for example.
In such cases it's possible to use a different profile from native and create a NativeEnvironmentRepository
Bean:
@Bean
public NativeEnvironmentRepository environmentRepository(NativeEnvironmentRepositoryFactory factory,
NativeEnvironmentProperties environmentProperties) {
return factory.build(environmentProperties);
}
Comment From: ryanjbaxter
Can you provide a more complete example of the problem? I am not sure I understand what the issue or suggestion is.
Comment From: andersonfaria-hotmart
Documentation does not say about the possibility to create the NativeEnvironmentRepository, only says about the spring.profiles.active=native
.
It could help someone else this information. I spent some time to figure out this.
Comment From: ryanjbaxter
That is true of every bean that is conditionally activated. If the bean is not created for some reason you have the option to create it yourself. We don't typically document those things, we try to document functionality instead.
Comment From: andersonfaria-hotmart
This documentation could be helpful in cases when someone needs to manage different profiles, as I mentioned. I spent some time figuring it out...
Comment From: ryanjbaxter
So why not activate multiple profiles?
Comment From: andersonfaria-hotmart
Well, I tried it, but didn't work. I don't know why but the only way for me was creating the NativeEnvironmentRepository
Comment From: ryanjbaxter
It should work. In fact we explicitely call that out in the documentation as a way of supporting multiple EnvironmentRepositorys https://docs.spring.io/spring-cloud-config/reference/server/environment-repository/composite-repositories.html
Comment From: andersonfaria-hotmart
But that wasn't the problem. The NativeEnvironmentRepository was needed to use one repository (native) with multiple profiles
Comment From: ryanjbaxter
The additional profiles were unrelated to the config server?
Comment From: andersonfaria-hotmart
In my specific case I intended to use config server for resource bundles to another apis. But I needed to use it with local files, so I needed to use the profile=native. I tried to use 2 profiles at the same time (native and production or native and staging) but this didn't work. So I created the NativeEnvironmentRepository and used the desired profile with the respective properties
Comment From: ryanjbaxter
Can you provide a sample that reproduces the problem?
Comment From: andersonfaria-hotmart
I'll create a sample project and share it here :)
Comment From: spring-cloud-issues
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Comment From: spring-cloud-issues
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.