diff --git a/reference/html/appendix.html b/reference/html/appendix.html new file mode 100644 index 00000000..4408f0df --- /dev/null +++ b/reference/html/appendix.html @@ -0,0 +1,318 @@ + + + + + + + +Common application properties + + + + + + + + + + +
+
+

Appendix A: Common application properties

+
+
+

Various properties can be specified inside your application.properties file, inside your application.yml file, or as command line switches. +This appendix provides a list of common Spring Cloud Commons properties and references to the underlying classes that consume them.

+
+
+ + + + + +
+ + +Property contributions can come from additional jar files on your classpath, so you should not consider this an exhaustive list. +Also, you can define your own properties. +
+
+ +++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameDefaultDescription

spring.cloud.compatibility-verifier.compatible-boot-versions

2.1.x

Default accepted versions for the Spring Boot dependency. You can set {@code x} for the patch version if you don’t want to specify a concrete value. Example: {@code 3.4.x}

spring.cloud.compatibility-verifier.enabled

false

Enables creation of Spring Cloud compatibility verification.

spring.cloud.config.allow-override

true

Flag to indicate that {@link #isOverrideSystemProperties() systemPropertiesOverride} can be used. Set to false to prevent users from changing the default accidentally. Default true.

spring.cloud.config.override-none

false

Flag to indicate that when {@link #setAllowOverride(boolean) allowOverride} is true, external properties should take lowest priority and should not override any existing property sources (including local config files). Default false.

spring.cloud.config.override-system-properties

true

Flag to indicate that the external properties should override system properties. Default true.

spring.cloud.discovery.client.composite-indicator.enabled

true

Enables discovery client composite health indicator.

spring.cloud.discovery.client.health-indicator.enabled

true

spring.cloud.discovery.client.health-indicator.include-description

false

spring.cloud.discovery.client.simple.instances

spring.cloud.discovery.client.simple.local.instance-id

The unique identifier or name for the service instance.

spring.cloud.discovery.client.simple.local.metadata

Metadata for the service instance. Can be used by discovery clients to modify their behaviour per instance, e.g. when load balancing.

spring.cloud.discovery.client.simple.local.service-id

The identifier or name for the service. Multiple instances might share the same service ID.

spring.cloud.discovery.client.simple.local.uri

The URI of the service instance. Will be parsed to extract the scheme, host, and port.

spring.cloud.discovery.client.simple.order

spring.cloud.discovery.enabled

true

Enables discovery client health indicators.

spring.cloud.features.enabled

true

Enables the features endpoint.

spring.cloud.httpclientfactories.apache.enabled

true

Enables creation of Apache Http Client factory beans.

spring.cloud.httpclientfactories.ok.enabled

true

Enables creation of OK Http Client factory beans.

spring.cloud.hypermedia.refresh.fixed-delay

5000

spring.cloud.hypermedia.refresh.initial-delay

10000

spring.cloud.inetutils.default-hostname

localhost

The default hostname. Used in case of errors.

spring.cloud.inetutils.default-ip-address

127.0.0.1

The default IP address. Used in case of errors.

spring.cloud.inetutils.ignored-interfaces

List of Java regular expressions for network interfaces that will be ignored.

spring.cloud.inetutils.preferred-networks

List of Java regular expressions for network addresses that will be preferred.

spring.cloud.inetutils.timeout-seconds

1

Timeout, in seconds, for calculating hostname.

spring.cloud.inetutils.use-only-site-local-interfaces

false

Whether to use only interfaces with site local addresses. See {@link InetAddress#isSiteLocalAddress()} for more details.

spring.cloud.loadbalancer.retry.enabled

true

spring.cloud.loadbalancer.ribbon.enabled

true

Causes RibbonLoadBalancerClient to be used by default.

spring.cloud.refresh.enabled

true

Enables autoconfiguration for the refresh scope and associated features.

spring.cloud.refresh.extra-refreshable

true

Additional class names for beans to post process into refresh scope.

spring.cloud.service-registry.auto-registration.enabled

true

Whether service auto-registration is enabled. Defaults to true.

spring.cloud.service-registry.auto-registration.fail-fast

false

Whether startup fails if there is no AutoServiceRegistration. Defaults to false.

spring.cloud.service-registry.auto-registration.register-management

true

Whether to register the management as a service. Defaults to true.

spring.cloud.util.enabled

true

Enables creation of Spring Cloud utility beans.

+
+
+
+ + + + + + + \ No newline at end of file diff --git a/reference/html/index.html b/reference/html/index.html index ce1165a7..66a20f7c 100644 --- a/reference/html/index.html +++ b/reference/html/index.html @@ -96,47 +96,77 @@ $(addBlockSwitches);
Table of Contents
@@ -181,7 +211,7 @@ See the following links for more information:

Spring Cloud is released under the non-restrictive Apache 2.0 license. -If you would like to contribute to this section of the documentation or if you find an error, you can find the source code and issue trackers for the project at github. +If you would like to contribute to this section of the documentation or if you find an error, you can find the source code and issue trackers for the project at {docslink}[github]. @@ -189,7 +219,7 @@ If you would like to contribute to this section of the documentation or if you f
-

Spring Cloud Context: Application Context Services

+

1. Spring Cloud Context: Application Context Services

Spring Boot has an opinionated view of how to build an application with Spring. @@ -197,7 +227,7 @@ For instance, it has conventional locations for common configuration files and h Spring Cloud builds on top of that and adds a few features that probably all components in a system would use or occasionally need.

-

The Bootstrap Application Context

+

1.1. The Bootstrap Application Context

A Spring Cloud application operates by creating a “bootstrap” context, which is a parent context for the main application. It is responsible for loading configuration properties from the external sources and for decrypting properties in the local external configuration files. @@ -231,7 +261,7 @@ must set it in bootstrap.[properties | yml].

-

Application Context Hierarchies

+

1.2. Application Context Hierarchies

If you build an application context from SpringApplication or SpringApplicationBuilder, then the Bootstrap context is added as a parent to that context. It is a feature of Spring that child contexts inherit property sources and profiles from their parent, so the “main” application context contains additional property sources, compared to building the same context without Spring Cloud Config. @@ -271,7 +301,7 @@ Thus, sibling contexts, in particular, do not need to have the same profiles or

-

Changing the Location of Bootstrap Properties

+

1.3. Changing the Location of Bootstrap Properties

The bootstrap.yml (or .properties) location can be specified by setting spring.cloud.bootstrap.name (default: bootstrap) or spring.cloud.bootstrap.location (default: empty) — for example, in System properties. Those properties behave like the spring.config.* variants with the same name. @@ -281,7 +311,7 @@ context you are building), properties in that profile get loaded as well, the sa

-

Overriding the Values of Remote Properties

+

1.4. Overriding the Values of Remote Properties

The property sources that are added to your application by the bootstrap context are often “remote” (from example, from Spring Cloud Config Server). By default, they cannot be overridden locally. @@ -300,7 +330,7 @@ Once that flag is set, two finer-grained settings control the location of the re

-

Customizing the Bootstrap Configuration

+

1.5. Customizing the Bootstrap Configuration

The bootstrap context can be set to do anything you like by adding entries to /META-INF/spring.factories under a key named org.springframework.cloud.bootstrap.BootstrapConfiguration. This holds a comma-separated list of Spring @Configuration classes that are used to create the context. @@ -328,7 +358,7 @@ Then, all @Beans of type ApplicationContextInitializer

-

Customizing the Bootstrap Property Sources

+

1.6. Customizing the Bootstrap Property Sources

The default property source for external configuration added by the bootstrap process is the Spring Cloud Config Server, but you can add additional sources by adding beans of type PropertySourceLocator to the bootstrap context (through spring.factories). For instance, you can insert additional properties from a different server or from a database.

@@ -364,7 +394,7 @@ It already has its normal Spring Boot-provided property sources, so you can use
-

Logging Configuration

+

1.7. Logging Configuration

If you are going to use Spring Boot to configure log settings than you should place this configuration in `bootstrap.[yml | properties] @@ -385,7 +415,7 @@ using custom.loggin.logpath will not be recognized by Spring Cloud

-

Environment Changes

+

1.8. Environment Changes

The application listens for an EnvironmentChangeEvent and reacts to the change in a couple of standard ways (additional ApplicationListeners can be added as @Beans by the user in the normal way). When an EnvironmentChangeEvent is observed, it has a list of key values that have changed, and the application uses those to:

@@ -416,7 +446,7 @@ To address those concerns, we have @RefreshScope.

-

Refresh Scope

+

1.9. Refresh Scope

When there is a configuration change, a Spring @Bean that is marked as @RefreshScope gets special treatment. This feature addresses the problem of stateful beans that only get their configuration injected when they are initialized. @@ -482,7 +512,7 @@ In that case, it is rebuilt on a refresh and its dependencies are re-injected. A

-

Encryption and Decryption

+

1.10. Encryption and Decryption

Spring Cloud has an Environment pre-processor for decrypting property values locally. It follows the same rules as the Config Server and has the same external configuration through encrypt.*. @@ -511,7 +541,7 @@ See the following links for more information:

-

Endpoints

+

1.11. Endpoints

For a Spring Boot Actuator application, some additional management endpoints are available. You can use:

@@ -548,13 +578,13 @@ will also be disabled since they are just a special case of /actuator/rest
-

Spring Cloud Commons: Common Abstractions

+

2. Spring Cloud Commons: Common Abstractions

Patterns such as service discovery, load balancing, and circuit breakers lend themselves to a common abstraction layer that can be consumed by all Spring Cloud clients, independent of the implementation (for example, discovery with Eureka or Consul).

-

@EnableDiscoveryClient

+

2.1. @EnableDiscoveryClient

Spring Cloud Commons provides the @EnableDiscoveryClient annotation. This looks for implementations of the DiscoveryClient and ReactiveDiscoveryClient interfaces with META-INF/spring.factories. @@ -584,7 +614,7 @@ You can put a DiscoveryClient implementation on the classpath to ca

-

Health Indicator

+

2.1.1. Health Indicator

Commons creates a Spring Boot HealthIndicator that DiscoveryClient implementations can participate in by implementing DiscoveryHealthIndicator. To disable the composite HealthIndicator, set spring.cloud.discovery.client.composite-indicator.enabled=false. @@ -595,7 +625,7 @@ Otherwise, it can bubble up as the description of the rolled up

-

Ordering DiscoveryClient instances

+

2.1.2. Ordering DiscoveryClient instances

DiscoveryClient interface extends Ordered. This is useful when using multiple discovery clients, as it allows you to define the order of the returned discovery clients, similar to @@ -610,7 +640,7 @@ implementations provided by Spring Cloud, among others ConsulDiscoveryCli

-

ServiceRegistry

+

2.2. ServiceRegistry

Commons now provides a ServiceRegistry interface that provides methods such as register(Registration) and deregister(Registration), which let you provide custom registered services. Registration is a marker interface.

@@ -659,7 +689,7 @@ correct Registry implementation for the ServiceRegistry
-

ServiceRegistry Auto-Registration

+

2.2.1. ServiceRegistry Auto-Registration

By default, the ServiceRegistry implementation auto-registers the running service. To disable that behavior, you can set: @@ -667,7 +697,7 @@ To disable that behavior, you can set: * spring.cloud.service-registry.auto-registration.enabled=false to disable the behavior through configuration.

-
ServiceRegistry Auto-Registration Events
+
ServiceRegistry Auto-Registration Events

There are two events that will be fired when a service auto-registers. The first event, called InstancePreRegisteredEvent, is fired before the service is registered. The second @@ -689,7 +719,7 @@ These events will not be fired if spring.cloud.service-registry.auto-regis

-

Service Registry Actuator Endpoint

+

2.2.2. Service Registry Actuator Endpoint

Spring Cloud Commons provides a /service-registry actuator endpoint. This endpoint relies on a Registration bean in the Spring Application Context. @@ -702,7 +732,7 @@ For instance, Eureka’s supported statuses are UP, DOWN<

-

Spring RestTemplate as a Load Balancer Client

+

2.3. Spring RestTemplate as a Load Balancer Client

RestTemplate can be automatically configured to use a Load-balancer client under the hood. To create a load-balanced RestTemplate, create a RestTemplate @Bean and use the @LoadBalanced qualifier, as shown in the following example:

@@ -746,7 +776,7 @@ Individual applications must create it.

The URI needs to use a virtual host name (that is, a service name, not a host name). The Ribbon client is used to create a full physical address. -See RibbonAutoConfiguration for details of how the RestTemplate is set up.

+See {githubroot}/spring-cloud-netflix/blob/master/spring-cloud-netflix-ribbon/src/main/java/org/springframework/cloud/netflix/ribbon/RibbonAutoConfiguration.java[RibbonAutoConfiguration] for details of how the RestTemplate is set up.

@@ -780,7 +810,7 @@ to override it, you can set the property spring.cloud.loadbalancer.ribbon.
-

Spring WebClient as a Load Balancer Client

+

2.4. Spring WebClient as a Load Balancer Client

WebClient can be automatically configured to use a load-balancer client. To create a load-balanced WebClient, create a WebClient.Builder @Bean and use the @LoadBalanced qualifier, as shown in the following example:

@@ -790,11 +820,11 @@ To create a load-balanced WebClient, create a WebClient.Build
@Configuration
 public class MyConfiguration {
 
-	@Bean
-	@LoadBalanced
-	public WebClient.Builder loadBalancedWebClientBuilder() {
-		return WebClient.builder();
-	}
+    @Bean
+    @LoadBalanced
+    public WebClient.Builder loadBalancedWebClientBuilder() {
+        return WebClient.builder();
+    }
 }
 
 public class MyClass {
@@ -803,7 +833,7 @@ public class MyClass {
 
     public Mono<String> doOtherStuff() {
         return webClientBuilder.build().get().uri("http://stores/stores")
-        				.retrieve().bodyToMono(String.class);
+                        .retrieve().bodyToMono(String.class);
     }
 }
@@ -848,7 +878,7 @@ the value of spring.cache.type to none.
-

Retrying Failed Requests

+

2.4.1. Retrying Failed Requests

A load-balanced RestTemplate can be configured to retry failed requests. By default, this logic is disabled. @@ -870,8 +900,8 @@ public class MyConfiguration { return new LoadBalancedRetryFactory() { @Override public BackOffPolicy createBackOffPolicy(String service) { - return new ExponentialBackOffPolicy(); - } + return new ExponentialBackOffPolicy(); + } }; } } @@ -929,7 +959,7 @@ public class MyConfiguration {

-

Multiple RestTemplate objects

+

2.5. Multiple RestTemplate objects

If you want a RestTemplate that is not load-balanced, create a RestTemplate bean and inject it. To access the load-balanced RestTemplate, use the @LoadBalanced qualifier when you create your @Bean, as shown in the following example:\

@@ -996,9 +1026,9 @@ If you see errors such as java.lang.IllegalArgumentException: Can not set
-

Spring WebFlux WebClient as a Load Balancer Client

+

2.6. Spring WebFlux WebClient as a Load Balancer Client

-

Spring WebFlux WebClient with Reactive Load Balancer

+

2.6.1. Spring WebFlux WebClient with Reactive Load Balancer

WebClient can be configured to use the ReactiveLoadBalancer. If you add org.springframework.cloud:spring-cloud-starter-loadbalancer to your project, @@ -1029,7 +1059,7 @@ The ReactorLoadBalancerClient is used to create a full physical add

-

Spring WebFlux WebClient with non-reactive Load Balancer Client

+

2.6.2. Spring WebFlux WebClient with non-reactive Load Balancer Client

If you you don’t have org.springframework.cloud:spring-cloud-starter-loadbalancer in your project, but you do have spring-cloud-starter-netflix-ribbon, you can still use WebClient with LoadBalancerClient. LoadBalancerExchangeFilterFunction @@ -1067,7 +1097,7 @@ instead.

-

Passing your own Load-Balancer Client configuration

+

2.6.3. Passing your own Load-Balancer Client configuration

You can also use the @LoadBalancerClient annotation to pass your own load-balancer client configuration, passing the name of the load-balancer client and the configuration class, like so:

@@ -1077,11 +1107,11 @@ instead.

@LoadBalancerClient(value = "stores", configuration = StoresLoadBalancerClientConfiguration.class) public class MyConfiguration { - @Bean - @LoadBalanced - public WebClient.Builder loadBalancedWebClientBuilder() { - return WebClient.builder(); - } + @Bean + @LoadBalanced + public WebClient.Builder loadBalancedWebClientBuilder() { + return WebClient.builder(); + } }
@@ -1094,18 +1124,18 @@ public class MyConfiguration { @LoadBalancerClients({@LoadBalancerClient(value = "stores", configuration = StoresLoadBalancerClientConfiguration.class), @LoadBalancerClient(value = "customers", configuration = CustomersLoadBalancerClientConfiguration.class)}) public class MyConfiguration { - @Bean - @LoadBalanced - public WebClient.Builder loadBalancedWebClientBuilder() { - return WebClient.builder(); - } + @Bean + @LoadBalanced + public WebClient.Builder loadBalancedWebClientBuilder() { + return WebClient.builder(); + } }
-

Ignore Network Interfaces

+

2.7. Ignore Network Interfaces

Sometimes, it is useful to ignore certain named network interfaces so that they can be excluded from Service Discovery registration (for example, when running in a Docker container). A list of regular expressions can be set to cause the desired network interfaces to be ignored. @@ -1153,7 +1183,7 @@ The following configuration ignores the docker0 interface and all i

-

HTTP Client Factories

+

2.8. HTTP Client Factories

Spring Cloud Commons provides beans for creating both Apache HTTP clients (ApacheHttpClientFactory) and OK HTTP clients (OkHttpClientFactory). The OkHttpClientFactory bean is created only if the OK HTTP jar is on the classpath. @@ -1164,14 +1194,14 @@ You can also disable the creation of these beans by setting spring.cloud.h

-

Enabled Features

+

2.9. Enabled Features

Spring Cloud Commons provides a /features actuator endpoint. This endpoint returns features available on the classpath and whether they are enabled. The information returned includes the feature type, name, version, and vendor.

-

Feature types

+

2.9.1. Feature types

There are two types of 'features': abstract and named.

@@ -1185,7 +1215,7 @@ The version displayed is bean.getClass().getPackage().getImplementationVer
-

Declaring features

+

2.9.2. Declaring features

Any module can declare any number of HasFeature beans, as shown in the following examples:

@@ -1219,7 +1249,7 @@ HasFeatures localFeatures() {
-

Spring Cloud Compatibility Verification

+

2.10. Spring Cloud Compatibility Verification

Due to the fact that some users have problem with setting up Spring Cloud application, we’ve decided to add a compatibility verification mechanism. It will break if your current setup is not compatible @@ -1263,20 +1293,20 @@ of compatible Spring Boot versions.

-

Introduction

+

4. Introduction

Spring Cloud Circuit breaker provides an abstraction across different circuit breaker implementations. It provides a consistent API to use in your applications allowing you the developer to choose the circuit breaker implementation that best fits your needs for your app.

-

Supported Implementations

+

4.1. Supported Implementations

  • @@ -1297,7 +1327,7 @@ It provides a consistent API to use in your applications allowing you the develo
-

Core Concepts

+

5. Core Concepts

To create a circuit breaker in your code you can use the CircuitBreakerFactory API. When you include a Spring Cloud Circuit Breaker starter on your classpath a bean implementing this API will automatically be created for you. @@ -1309,17 +1339,17 @@ A very simple example of using this API is given below

@Service
 public static class DemoControllerService {
-	private RestTemplate rest;
-	private CircuitBreakerFactory cbFactory;
+    private RestTemplate rest;
+    private CircuitBreakerFactory cbFactory;
 
-	public DemoControllerService(RestTemplate rest, CircuitBreakerFactory cbFactory) {
-		this.rest = rest;
-		this.cbFactory = cbFactory;
-	}
+    public DemoControllerService(RestTemplate rest, CircuitBreakerFactory cbFactory) {
+        this.rest = rest;
+        this.cbFactory = cbFactory;
+    }
 
-	public String slow() {
-		return cbFactory.create("slow").run(() -> rest.getForObject("/slow", String.class), throwable -> "fallback");
-	}
+    public String slow() {
+        return cbFactory.create("slow").run(() -> rest.getForObject("/slow", String.class), throwable -> "fallback");
+    }
 
 }
@@ -1335,7 +1365,7 @@ The function will be passed the Throwable that caused the fallback You can optionally exclude the fallback if you do not want to provide one.

-

Circuit Breakers In Reactive Code

+

5.1. Circuit Breakers In Reactive Code

If Project Reactor is on the class path then you can also use ReactiveCircuitBreakerFactory for your reactive code.

@@ -1345,19 +1375,19 @@ You can optionally exclude the fallback if you do not want to provide one.

@Service
 public static class DemoControllerService {
-	private ReactiveCircuitBreakerFactory cbFactory;
-	private WebClient webClient;
+    private ReactiveCircuitBreakerFactory cbFactory;
+    private WebClient webClient;
 
 
-	public DemoControllerService(WebClient webClient, ReactiveCircuitBreakerFactory cbFactory) {
-		this.webClient = webClient;
-		this.cbFactory = cbFactory;
-	}
+    public DemoControllerService(WebClient webClient, ReactiveCircuitBreakerFactory cbFactory) {
+        this.webClient = webClient;
+        this.cbFactory = cbFactory;
+    }
 
-	public Mono<String> slow() {
-		return webClient.get().uri("/slow").retrieve().bodyToMono(String.class).transform(
-		it -> cbFactory.create("slow").run(it, throwable -> return Mono.just("fallback")));
-	}
+    public Mono<String> slow() {
+        return webClient.get().uri("/slow").retrieve().bodyToMono(String.class).transform(
+        it -> cbFactory.create("slow").run(it, throwable -> return Mono.just("fallback")));
+    }
 }
@@ -1373,7 +1403,7 @@ that caused the failure.

-

Configuration

+

6. Configuration

You can configure your circuit breakers using by creating beans of type Customizer. @@ -1401,6 +1431,14 @@ the links below

+
+

7. Configuration Properties

+
+
+

To see the list of all Sleuth related configuration properties please check the Appendix page.

+
+
+
diff --git a/reference/html/spring-cloud-commons.html b/reference/html/spring-cloud-commons.html index ce1165a7..66a20f7c 100644 --- a/reference/html/spring-cloud-commons.html +++ b/reference/html/spring-cloud-commons.html @@ -96,47 +96,77 @@ $(addBlockSwitches);
Table of Contents
@@ -181,7 +211,7 @@ See the following links for more information:

Spring Cloud is released under the non-restrictive Apache 2.0 license. -If you would like to contribute to this section of the documentation or if you find an error, you can find the source code and issue trackers for the project at github. +If you would like to contribute to this section of the documentation or if you find an error, you can find the source code and issue trackers for the project at {docslink}[github]. @@ -189,7 +219,7 @@ If you would like to contribute to this section of the documentation or if you f
-

Spring Cloud Context: Application Context Services

+

1. Spring Cloud Context: Application Context Services

Spring Boot has an opinionated view of how to build an application with Spring. @@ -197,7 +227,7 @@ For instance, it has conventional locations for common configuration files and h Spring Cloud builds on top of that and adds a few features that probably all components in a system would use or occasionally need.

-

The Bootstrap Application Context

+

1.1. The Bootstrap Application Context

A Spring Cloud application operates by creating a “bootstrap” context, which is a parent context for the main application. It is responsible for loading configuration properties from the external sources and for decrypting properties in the local external configuration files. @@ -231,7 +261,7 @@ must set it in bootstrap.[properties | yml].

-

Application Context Hierarchies

+

1.2. Application Context Hierarchies

If you build an application context from SpringApplication or SpringApplicationBuilder, then the Bootstrap context is added as a parent to that context. It is a feature of Spring that child contexts inherit property sources and profiles from their parent, so the “main” application context contains additional property sources, compared to building the same context without Spring Cloud Config. @@ -271,7 +301,7 @@ Thus, sibling contexts, in particular, do not need to have the same profiles or

-

Changing the Location of Bootstrap Properties

+

1.3. Changing the Location of Bootstrap Properties

The bootstrap.yml (or .properties) location can be specified by setting spring.cloud.bootstrap.name (default: bootstrap) or spring.cloud.bootstrap.location (default: empty) — for example, in System properties. Those properties behave like the spring.config.* variants with the same name. @@ -281,7 +311,7 @@ context you are building), properties in that profile get loaded as well, the sa

-

Overriding the Values of Remote Properties

+

1.4. Overriding the Values of Remote Properties

The property sources that are added to your application by the bootstrap context are often “remote” (from example, from Spring Cloud Config Server). By default, they cannot be overridden locally. @@ -300,7 +330,7 @@ Once that flag is set, two finer-grained settings control the location of the re

-

Customizing the Bootstrap Configuration

+

1.5. Customizing the Bootstrap Configuration

The bootstrap context can be set to do anything you like by adding entries to /META-INF/spring.factories under a key named org.springframework.cloud.bootstrap.BootstrapConfiguration. This holds a comma-separated list of Spring @Configuration classes that are used to create the context. @@ -328,7 +358,7 @@ Then, all @Beans of type ApplicationContextInitializer

-

Customizing the Bootstrap Property Sources

+

1.6. Customizing the Bootstrap Property Sources

The default property source for external configuration added by the bootstrap process is the Spring Cloud Config Server, but you can add additional sources by adding beans of type PropertySourceLocator to the bootstrap context (through spring.factories). For instance, you can insert additional properties from a different server or from a database.

@@ -364,7 +394,7 @@ It already has its normal Spring Boot-provided property sources, so you can use
-

Logging Configuration

+

1.7. Logging Configuration

If you are going to use Spring Boot to configure log settings than you should place this configuration in `bootstrap.[yml | properties] @@ -385,7 +415,7 @@ using custom.loggin.logpath will not be recognized by Spring Cloud

-

Environment Changes

+

1.8. Environment Changes

The application listens for an EnvironmentChangeEvent and reacts to the change in a couple of standard ways (additional ApplicationListeners can be added as @Beans by the user in the normal way). When an EnvironmentChangeEvent is observed, it has a list of key values that have changed, and the application uses those to:

@@ -416,7 +446,7 @@ To address those concerns, we have @RefreshScope.

-

Refresh Scope

+

1.9. Refresh Scope

When there is a configuration change, a Spring @Bean that is marked as @RefreshScope gets special treatment. This feature addresses the problem of stateful beans that only get their configuration injected when they are initialized. @@ -482,7 +512,7 @@ In that case, it is rebuilt on a refresh and its dependencies are re-injected. A

-

Encryption and Decryption

+

1.10. Encryption and Decryption

Spring Cloud has an Environment pre-processor for decrypting property values locally. It follows the same rules as the Config Server and has the same external configuration through encrypt.*. @@ -511,7 +541,7 @@ See the following links for more information:

-

Endpoints

+

1.11. Endpoints

For a Spring Boot Actuator application, some additional management endpoints are available. You can use:

@@ -548,13 +578,13 @@ will also be disabled since they are just a special case of /actuator/rest
-

Spring Cloud Commons: Common Abstractions

+

2. Spring Cloud Commons: Common Abstractions

Patterns such as service discovery, load balancing, and circuit breakers lend themselves to a common abstraction layer that can be consumed by all Spring Cloud clients, independent of the implementation (for example, discovery with Eureka or Consul).

-

@EnableDiscoveryClient

+

2.1. @EnableDiscoveryClient

Spring Cloud Commons provides the @EnableDiscoveryClient annotation. This looks for implementations of the DiscoveryClient and ReactiveDiscoveryClient interfaces with META-INF/spring.factories. @@ -584,7 +614,7 @@ You can put a DiscoveryClient implementation on the classpath to ca

-

Health Indicator

+

2.1.1. Health Indicator

Commons creates a Spring Boot HealthIndicator that DiscoveryClient implementations can participate in by implementing DiscoveryHealthIndicator. To disable the composite HealthIndicator, set spring.cloud.discovery.client.composite-indicator.enabled=false. @@ -595,7 +625,7 @@ Otherwise, it can bubble up as the description of the rolled up

-

Ordering DiscoveryClient instances

+

2.1.2. Ordering DiscoveryClient instances

DiscoveryClient interface extends Ordered. This is useful when using multiple discovery clients, as it allows you to define the order of the returned discovery clients, similar to @@ -610,7 +640,7 @@ implementations provided by Spring Cloud, among others ConsulDiscoveryCli

-

ServiceRegistry

+

2.2. ServiceRegistry

Commons now provides a ServiceRegistry interface that provides methods such as register(Registration) and deregister(Registration), which let you provide custom registered services. Registration is a marker interface.

@@ -659,7 +689,7 @@ correct Registry implementation for the ServiceRegistry
-

ServiceRegistry Auto-Registration

+

2.2.1. ServiceRegistry Auto-Registration

By default, the ServiceRegistry implementation auto-registers the running service. To disable that behavior, you can set: @@ -667,7 +697,7 @@ To disable that behavior, you can set: * spring.cloud.service-registry.auto-registration.enabled=false to disable the behavior through configuration.

-
ServiceRegistry Auto-Registration Events
+
ServiceRegistry Auto-Registration Events

There are two events that will be fired when a service auto-registers. The first event, called InstancePreRegisteredEvent, is fired before the service is registered. The second @@ -689,7 +719,7 @@ These events will not be fired if spring.cloud.service-registry.auto-regis

-

Service Registry Actuator Endpoint

+

2.2.2. Service Registry Actuator Endpoint

Spring Cloud Commons provides a /service-registry actuator endpoint. This endpoint relies on a Registration bean in the Spring Application Context. @@ -702,7 +732,7 @@ For instance, Eureka’s supported statuses are UP, DOWN<

-

Spring RestTemplate as a Load Balancer Client

+

2.3. Spring RestTemplate as a Load Balancer Client

RestTemplate can be automatically configured to use a Load-balancer client under the hood. To create a load-balanced RestTemplate, create a RestTemplate @Bean and use the @LoadBalanced qualifier, as shown in the following example:

@@ -746,7 +776,7 @@ Individual applications must create it.

The URI needs to use a virtual host name (that is, a service name, not a host name). The Ribbon client is used to create a full physical address. -See RibbonAutoConfiguration for details of how the RestTemplate is set up.

+See {githubroot}/spring-cloud-netflix/blob/master/spring-cloud-netflix-ribbon/src/main/java/org/springframework/cloud/netflix/ribbon/RibbonAutoConfiguration.java[RibbonAutoConfiguration] for details of how the RestTemplate is set up.

@@ -780,7 +810,7 @@ to override it, you can set the property spring.cloud.loadbalancer.ribbon.
-

Spring WebClient as a Load Balancer Client

+

2.4. Spring WebClient as a Load Balancer Client

WebClient can be automatically configured to use a load-balancer client. To create a load-balanced WebClient, create a WebClient.Builder @Bean and use the @LoadBalanced qualifier, as shown in the following example:

@@ -790,11 +820,11 @@ To create a load-balanced WebClient, create a WebClient.Build
@Configuration
 public class MyConfiguration {
 
-	@Bean
-	@LoadBalanced
-	public WebClient.Builder loadBalancedWebClientBuilder() {
-		return WebClient.builder();
-	}
+    @Bean
+    @LoadBalanced
+    public WebClient.Builder loadBalancedWebClientBuilder() {
+        return WebClient.builder();
+    }
 }
 
 public class MyClass {
@@ -803,7 +833,7 @@ public class MyClass {
 
     public Mono<String> doOtherStuff() {
         return webClientBuilder.build().get().uri("http://stores/stores")
-        				.retrieve().bodyToMono(String.class);
+                        .retrieve().bodyToMono(String.class);
     }
 }
@@ -848,7 +878,7 @@ the value of spring.cache.type to none.
-

Retrying Failed Requests

+

2.4.1. Retrying Failed Requests

A load-balanced RestTemplate can be configured to retry failed requests. By default, this logic is disabled. @@ -870,8 +900,8 @@ public class MyConfiguration { return new LoadBalancedRetryFactory() { @Override public BackOffPolicy createBackOffPolicy(String service) { - return new ExponentialBackOffPolicy(); - } + return new ExponentialBackOffPolicy(); + } }; } } @@ -929,7 +959,7 @@ public class MyConfiguration {

-

Multiple RestTemplate objects

+

2.5. Multiple RestTemplate objects

If you want a RestTemplate that is not load-balanced, create a RestTemplate bean and inject it. To access the load-balanced RestTemplate, use the @LoadBalanced qualifier when you create your @Bean, as shown in the following example:\

@@ -996,9 +1026,9 @@ If you see errors such as java.lang.IllegalArgumentException: Can not set
-

Spring WebFlux WebClient as a Load Balancer Client

+

2.6. Spring WebFlux WebClient as a Load Balancer Client

-

Spring WebFlux WebClient with Reactive Load Balancer

+

2.6.1. Spring WebFlux WebClient with Reactive Load Balancer

WebClient can be configured to use the ReactiveLoadBalancer. If you add org.springframework.cloud:spring-cloud-starter-loadbalancer to your project, @@ -1029,7 +1059,7 @@ The ReactorLoadBalancerClient is used to create a full physical add

-

Spring WebFlux WebClient with non-reactive Load Balancer Client

+

2.6.2. Spring WebFlux WebClient with non-reactive Load Balancer Client

If you you don’t have org.springframework.cloud:spring-cloud-starter-loadbalancer in your project, but you do have spring-cloud-starter-netflix-ribbon, you can still use WebClient with LoadBalancerClient. LoadBalancerExchangeFilterFunction @@ -1067,7 +1097,7 @@ instead.

-

Passing your own Load-Balancer Client configuration

+

2.6.3. Passing your own Load-Balancer Client configuration

You can also use the @LoadBalancerClient annotation to pass your own load-balancer client configuration, passing the name of the load-balancer client and the configuration class, like so:

@@ -1077,11 +1107,11 @@ instead.

@LoadBalancerClient(value = "stores", configuration = StoresLoadBalancerClientConfiguration.class) public class MyConfiguration { - @Bean - @LoadBalanced - public WebClient.Builder loadBalancedWebClientBuilder() { - return WebClient.builder(); - } + @Bean + @LoadBalanced + public WebClient.Builder loadBalancedWebClientBuilder() { + return WebClient.builder(); + } }
@@ -1094,18 +1124,18 @@ public class MyConfiguration { @LoadBalancerClients({@LoadBalancerClient(value = "stores", configuration = StoresLoadBalancerClientConfiguration.class), @LoadBalancerClient(value = "customers", configuration = CustomersLoadBalancerClientConfiguration.class)}) public class MyConfiguration { - @Bean - @LoadBalanced - public WebClient.Builder loadBalancedWebClientBuilder() { - return WebClient.builder(); - } + @Bean + @LoadBalanced + public WebClient.Builder loadBalancedWebClientBuilder() { + return WebClient.builder(); + } }
-

Ignore Network Interfaces

+

2.7. Ignore Network Interfaces

Sometimes, it is useful to ignore certain named network interfaces so that they can be excluded from Service Discovery registration (for example, when running in a Docker container). A list of regular expressions can be set to cause the desired network interfaces to be ignored. @@ -1153,7 +1183,7 @@ The following configuration ignores the docker0 interface and all i

-

HTTP Client Factories

+

2.8. HTTP Client Factories

Spring Cloud Commons provides beans for creating both Apache HTTP clients (ApacheHttpClientFactory) and OK HTTP clients (OkHttpClientFactory). The OkHttpClientFactory bean is created only if the OK HTTP jar is on the classpath. @@ -1164,14 +1194,14 @@ You can also disable the creation of these beans by setting spring.cloud.h

-

Enabled Features

+

2.9. Enabled Features

Spring Cloud Commons provides a /features actuator endpoint. This endpoint returns features available on the classpath and whether they are enabled. The information returned includes the feature type, name, version, and vendor.

-

Feature types

+

2.9.1. Feature types

There are two types of 'features': abstract and named.

@@ -1185,7 +1215,7 @@ The version displayed is bean.getClass().getPackage().getImplementationVer
-

Declaring features

+

2.9.2. Declaring features

Any module can declare any number of HasFeature beans, as shown in the following examples:

@@ -1219,7 +1249,7 @@ HasFeatures localFeatures() {
-

Spring Cloud Compatibility Verification

+

2.10. Spring Cloud Compatibility Verification

Due to the fact that some users have problem with setting up Spring Cloud application, we’ve decided to add a compatibility verification mechanism. It will break if your current setup is not compatible @@ -1263,20 +1293,20 @@ of compatible Spring Boot versions.

-

Introduction

+

4. Introduction

Spring Cloud Circuit breaker provides an abstraction across different circuit breaker implementations. It provides a consistent API to use in your applications allowing you the developer to choose the circuit breaker implementation that best fits your needs for your app.

-

Supported Implementations

+

4.1. Supported Implementations

  • @@ -1297,7 +1327,7 @@ It provides a consistent API to use in your applications allowing you the develo
-

Core Concepts

+

5. Core Concepts

To create a circuit breaker in your code you can use the CircuitBreakerFactory API. When you include a Spring Cloud Circuit Breaker starter on your classpath a bean implementing this API will automatically be created for you. @@ -1309,17 +1339,17 @@ A very simple example of using this API is given below

@Service
 public static class DemoControllerService {
-	private RestTemplate rest;
-	private CircuitBreakerFactory cbFactory;
+    private RestTemplate rest;
+    private CircuitBreakerFactory cbFactory;
 
-	public DemoControllerService(RestTemplate rest, CircuitBreakerFactory cbFactory) {
-		this.rest = rest;
-		this.cbFactory = cbFactory;
-	}
+    public DemoControllerService(RestTemplate rest, CircuitBreakerFactory cbFactory) {
+        this.rest = rest;
+        this.cbFactory = cbFactory;
+    }
 
-	public String slow() {
-		return cbFactory.create("slow").run(() -> rest.getForObject("/slow", String.class), throwable -> "fallback");
-	}
+    public String slow() {
+        return cbFactory.create("slow").run(() -> rest.getForObject("/slow", String.class), throwable -> "fallback");
+    }
 
 }
@@ -1335,7 +1365,7 @@ The function will be passed the Throwable that caused the fallback You can optionally exclude the fallback if you do not want to provide one.

-

Circuit Breakers In Reactive Code

+

5.1. Circuit Breakers In Reactive Code

If Project Reactor is on the class path then you can also use ReactiveCircuitBreakerFactory for your reactive code.

@@ -1345,19 +1375,19 @@ You can optionally exclude the fallback if you do not want to provide one.

@Service
 public static class DemoControllerService {
-	private ReactiveCircuitBreakerFactory cbFactory;
-	private WebClient webClient;
+    private ReactiveCircuitBreakerFactory cbFactory;
+    private WebClient webClient;
 
 
-	public DemoControllerService(WebClient webClient, ReactiveCircuitBreakerFactory cbFactory) {
-		this.webClient = webClient;
-		this.cbFactory = cbFactory;
-	}
+    public DemoControllerService(WebClient webClient, ReactiveCircuitBreakerFactory cbFactory) {
+        this.webClient = webClient;
+        this.cbFactory = cbFactory;
+    }
 
-	public Mono<String> slow() {
-		return webClient.get().uri("/slow").retrieve().bodyToMono(String.class).transform(
-		it -> cbFactory.create("slow").run(it, throwable -> return Mono.just("fallback")));
-	}
+    public Mono<String> slow() {
+        return webClient.get().uri("/slow").retrieve().bodyToMono(String.class).transform(
+        it -> cbFactory.create("slow").run(it, throwable -> return Mono.just("fallback")));
+    }
 }
@@ -1373,7 +1403,7 @@ that caused the failure.

-

Configuration

+

6. Configuration

You can configure your circuit breakers using by creating beans of type Customizer. @@ -1401,6 +1431,14 @@ the links below

+
+

7. Configuration Properties

+
+
+

To see the list of all Sleuth related configuration properties please check the Appendix page.

+
+
+