Users now need to create their own bean and qualify it, and Spring
Cloud will customize it (instead of providing the @Bean itself).
This is much better for users, since they remain in control of the
bean declarations, and can choose which one (if any) is @Primary.
It's a breaking change for some apps (if they rely on a
@LoadBalanced RestTemplate being automatically injected).
When the bootstrap properties are added back into the main Environment
we have to be careful that any source that is already there (such as
one that was added in a Spring Boot EnvironmentPostProcessor) is not
replaced in the wrong order.
Fixes gh-90
Use SystemEnvironmentPropertySource so that env vars can be
encrypted as well as property values (i.e. FOO_BAR will bind to
@Value("foo.bar")).
Fixes gh-89, fixes gh-87
When the RefreshEndpoint makes a new Environment it creates a new
ApplicationContext with (hopefully) empty sources. If the user has
set spring.main.sources it won't be empty, so we should take care
to mask it off in the process.
Fixes gh-79
Repots DOWN if there are errors in RefreshScope or
ConfigurationProperties rebinding, N.B. RefreshScope instantiates
its beans lazily after a refresh by default, so you won't see an
error until the bean is used.
Fixes gh-85
The fact that PropertySourceBootstrapConfiguration was re-using the
"bootstrap" property source name from the listener was a problem. The
listener has to be able to manage its own temporary property source name.
Fixes gh-83
The bootstrap.properties need to stick with the default properties
during the process of initializing the application.properties
otherwise the ordering ends up wrong because of the addLast()
semantics in an Environment merge. To do this is a bit ugly with
the additional constraint that the default properties has to
remain a MapPropertySource (so that other processors can append
to it if needed). So we created a custom extension of
MapPropertySource that also carries all the bootstrap properties
during the phase where the application.properties are being
processed, but unpacks them as soon as possible afterwards
in an ApplicationContextInitializer, preserving the order, but
making the bootstrap.properties available effectively for the
whole of the startup and initializaion phase of the main context.
The biggest problem addressed here is one where an
EnvironmentPostProcessor (reasonably) adds entries to the
defaultProperties in the bootstrap context, but then that
property source is not merged with the parent, or is merged
too late (because it only happens when the application context
parent is set). The result would be that things that were activated
during bootstrap would be not be activated in the main context, or
would be activated too late (early enough for beans to bind to but
not for other listeners and post processors to get access to the
additional properties).
See https://github.com/spring-cloud/spring-cloud-sleuth/issues/126
We only need one special name for a property source. In the end it
gets used twice, but this simplifies the logic a bit and ensures that
there is never a PropertySource with that name and things like
spring.application.name=bootstrap in it.
If user has @EnableDiscoveryClient but no implementation (e.g. if he
just has @EnableZuulProxy) the autoconfig will now kick in and
provide an instance of NoopDiscoveryClient.
Fixes gh-80