Skip to content

Commit bfd25e1

Browse files
committed
Document @primary for plain RestTemplate beans.
fixes gh-60
1 parent 0a58870 commit bfd25e1

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,11 +317,23 @@ for details of how the `RestTemplate` is set up.
317317
=== Multiple RestTemplate objects
318318

319319
If you want a `RestTemplate` that is not load balanced, create a `RestTemplate`
320-
bean and inject it as normal. To access the load balanced `RestTemplate use
321-
the provided `@LoadBalanced` `Qualifier`:
320+
bean and inject it as normal. To access the load balanced `RestTemplate use
321+
the provided `@LoadBalanced` `Qualifier`.
322+
323+
IMPORTANT: Notice the `@Primary` annotation on the plain `RestTemplate` declaration.
322324

323325
[source,java,indent=0]
324326
----
327+
@Configuration
328+
public class MyConfiguration {
329+
330+
@Primary
331+
@Bean
332+
RestTemplate restTemplate() {
333+
return new RestTemplate();
334+
}
335+
}
336+
325337
public class MyClass {
326338
@Autowired
327339
private RestTemplate restTemplate;

0 commit comments

Comments
 (0)