Skip to content

Commit 68c67df

Browse files
committed
Update RestTemplate creation documentation.
1 parent ad08ca5 commit 68c67df

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

docs/src/main/asciidoc/spring-cloud-commons.adoc

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,11 +293,22 @@ Patterns such as service discovery, load balancing and circuit breakers lend the
293293

294294
=== Spring RestTemplate as a Load Balancer Client
295295

296-
You can use Ribbon indirectly via an autoconfigured `RestTemplate`
297-
when RestTemplate is on the classpath and a `LoadBalancerClient` bean is defined):
296+
`RestTemplate` can be automatically configured to use ribbon. To create a load balanced `RestTemplate` create a `RestTemplate` `@Bean` and use the `@LoadBalanced` qualifier.
297+
298+
WARNING: A `RestTemplate` bean is no longer created via auto configuration. It must be created by individual applications.
298299

299300
[source,java,indent=0]
300301
----
302+
@Configuration
303+
public class MyConfiguration {
304+
305+
@LoadBalanced
306+
@Bean
307+
RestTemplate restTemplate() {
308+
return new RestTemplate();
309+
}
310+
}
311+
301312
public class MyClass {
302313
@Autowired
303314
private RestTemplate restTemplate;

0 commit comments

Comments
 (0)