You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/modules/ROOT/pages/spring-cloud-commons/common-abstractions.adoc
+85-2Lines changed: 85 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -218,6 +218,89 @@ IMPORTANT: Notice the use of the `@Primary` annotation on the plain `RestTemplat
218
218
219
219
TIP: If you see errors such as `java.lang.IllegalArgumentException: Can not set org.springframework.web.client.RestTemplate field com.my.app.Foo.restTemplate to com.sun.proxy.$Proxy89`, try injecting `RestOperations` or setting `spring.aop.proxyTargetClass=true`.
220
220
221
+
[[rest-template-builder-loadbalancer-client]]
222
+
== Using `@LoadBalanced RestTemplateBuilder` to create a LoadBalancer Client
223
+
224
+
You can also configure a `RestTemplate` to use a Load-Balancer client by annotating a
The URI needs to use a virtual host name (that is, a service name, not a host name).
254
+
The `BlockingLoadBalancerClient` is used to create a full physical address.
255
+
256
+
IMPORTANT: To use it, add xref:spring-cloud-commons/loadbalancer.adoc#spring-cloud-loadbalancer-starter[Spring Cloud LoadBalancer starter] to your project.
257
+
258
+
[[multiple-resttemplate-builder-beans]]
259
+
=== Multiple `RestTemplateBuilder` beans
260
+
261
+
If you want a `RestTemplateBuilder` that is not load-balanced, create a `RestTemplateBuilder` bean and inject it.
262
+
To access the load-balanced `RestTemplateBuilder`, use the `@LoadBalanced` qualifier when you create your `@Bean`, as the following example shows:
IMPORTANT: Notice the use of the `@Primary` annotation on the plain `RestTemplateBuilder` declaration in the preceding example to disambiguate the unqualified `@Autowired` injection.
302
+
303
+
221
304
[[rest-client-loadbalancer-client]]
222
305
== Spring RestClient as a LoadBalancer Client
223
306
@@ -256,7 +339,7 @@ IMPORTANT: To use it, add xref:spring-cloud-commons/loadbalancer.adoc#spring-clo
256
339
=== Multiple `RestClient.Builder` Objects
257
340
258
341
If you want a `RestClient.Builder` that is not load-balanced, create a `RestClient.Builder` bean and inject it.
259
-
To access the load-balanced `RestClient`, use the `@LoadBalanced` qualifier when you create your `@Bean`, as the following example shows:
342
+
To access the load-balanced `RestClient.Builder`, use the `@LoadBalanced` qualifier when you create your `@Bean`, as the following example shows:
260
343
261
344
[source,java,indent=0]
262
345
----
@@ -296,7 +379,7 @@ public class MyClass {
296
379
}
297
380
----
298
381
299
-
IMPORTANT: Notice the use of the `@Primary` annotation on the plain `RestTemplate` declaration in the preceding example to disambiguate the unqualified `@Autowired` injection.
382
+
IMPORTANT: Notice the use of the `@Primary` annotation on the plain `RestClient.Builder` declaration in the preceding example to disambiguate the unqualified `@Autowired` injection.
Copy file name to clipboardExpand all lines: spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/LoadBalancedRestClientIntegrationTests.java
-1Lines changed: 0 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -41,7 +41,6 @@ public class LoadBalancedRestClientIntegrationTests {
Copy file name to clipboardExpand all lines: spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/LoadBalancedRestTemplateBuilderIntegrationTests.java
0 commit comments