|
1 | 1 | /*
|
2 |
| - * Copyright 2012-2018 the original author or authors. |
| 2 | + * Copyright 2012-2019 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
24 | 24 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
25 | 25 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
26 | 26 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
| 27 | +import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; |
| 28 | +import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type; |
| 29 | +import org.springframework.boot.autoconfigure.condition.NoneNestedConditions; |
27 | 30 | import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
|
28 | 31 | import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration;
|
| 32 | +import org.springframework.boot.autoconfigure.web.client.RestTemplateAutoConfiguration.NotReactiveWebApplicationCondition; |
29 | 33 | import org.springframework.boot.web.client.RestTemplateBuilder;
|
30 | 34 | import org.springframework.boot.web.client.RestTemplateCustomizer;
|
31 | 35 | import org.springframework.context.annotation.Bean;
|
| 36 | +import org.springframework.context.annotation.Conditional; |
32 | 37 | import org.springframework.context.annotation.Configuration;
|
33 | 38 | import org.springframework.util.CollectionUtils;
|
34 | 39 | import org.springframework.web.client.RestTemplate;
|
|
43 | 48 | @Configuration
|
44 | 49 | @AutoConfigureAfter(HttpMessageConvertersAutoConfiguration.class)
|
45 | 50 | @ConditionalOnClass(RestTemplate.class)
|
| 51 | +@Conditional(NotReactiveWebApplicationCondition.class) |
46 | 52 | public class RestTemplateAutoConfiguration {
|
47 | 53 |
|
48 | 54 | private final ObjectProvider<HttpMessageConverters> messageConverters;
|
@@ -73,4 +79,17 @@ public RestTemplateBuilder restTemplateBuilder() {
|
73 | 79 | return builder;
|
74 | 80 | }
|
75 | 81 |
|
| 82 | + static class NotReactiveWebApplicationCondition extends NoneNestedConditions { |
| 83 | + |
| 84 | + NotReactiveWebApplicationCondition() { |
| 85 | + super(ConfigurationPhase.PARSE_CONFIGURATION); |
| 86 | + } |
| 87 | + |
| 88 | + @ConditionalOnWebApplication(type = Type.REACTIVE) |
| 89 | + private static class ReactiveWebApplication { |
| 90 | + |
| 91 | + } |
| 92 | + |
| 93 | + } |
| 94 | + |
76 | 95 | }
|
0 commit comments