Java Code Examples for org.springframework.boot.web.client.RestTemplateBuilder#build()

The following examples show how to use org.springframework.boot.web.client.RestTemplateBuilder#build() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BootstrapConfiguration.java    From chronus with Apache License 2.0 6 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public RestTemplate restTemplate(RestTemplateBuilder builder) {
    //先获取到converter列表
    List<HttpMessageConverter<?>> converters = builder.build().getMessageConverters();
    for (HttpMessageConverter<?> converter : converters) {
        //因为我们只想要jsonConverter支持对text/html的解析
        if (converter instanceof MappingJackson2HttpMessageConverter) {
            //先将原先支持的MediaType列表拷出
            List<MediaType> mediaTypeList = new ArrayList<>(converter.getSupportedMediaTypes());
            //加入对text/html的支持
            mediaTypeList.add(MediaType.TEXT_HTML);
            //将已经加入了text/html的MediaType支持列表设置为其支持的媒体类型列表
            ((MappingJackson2HttpMessageConverter) converter).setSupportedMediaTypes(mediaTypeList);
        }
    }
    return builder.build();
}
 
Example 2
Source File: EchoCloudConfig.java    From Milkomeda with MIT License 5 votes vote down vote up
@LoadBalanced
@Bean("echoCloudRestTemplate")
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
public RestTemplate simpleRestTemplate(RestTemplateBuilder builder, ClientHttpRequestFactory factory) {
    RestTemplate restTemplate = builder.build();
    restTemplate.setRequestFactory(factory);
    restTemplate.setErrorHandler(new EchoResponseErrorHandler());
    return restTemplate;
}
 
Example 3
Source File: VersionServiceImpl.java    From AuTe-Framework with Apache License 2.0 5 votes vote down vote up
private void loadProjectsWiremockVersion(EnvironmentProperties env, RestTemplateBuilder builder) {
    RestTemplate template = builder.build();
    env.getProjectStandMap().forEach((projectName, properties) -> {
        try {
            if (StringUtils.isNotEmpty(properties.getWireMockUrl())) {
                String url = getVersionUrl(properties);
                Version version = template.getForObject(url, Version.class);
                wiremockVersions.add(new WiremockVersion(projectName, version));
            }
        } catch (RestClientException e) {
            wiremockVersions.add(new WiremockVersion(projectName, Version.unknown()));
            log.error("Error while fetching project wiremock version", e);
        }
    });
}
 
Example 4
Source File: HelloApp.java    From Mastering-Distributed-Tracing with MIT License 4 votes vote down vote up
@Bean
public RestTemplate restTemplate(RestTemplateBuilder restTemplateBuilder) {
    return restTemplateBuilder.build();
}
 
Example 5
Source File: Application.java    From spring-cloud-huawei with Apache License 2.0 4 votes vote down vote up
@LoadBalanced
@Bean
public RestTemplate restTemplate(RestTemplateBuilder builder){
  return builder.build();
}
 
Example 6
Source File: Frontend.java    From brave-webmvc-example with MIT License 4 votes vote down vote up
@Autowired Frontend(RestTemplateBuilder restTemplateBuilder) {
  this.restTemplate = restTemplateBuilder.build();
}
 
Example 7
Source File: ContractRestClientApplication.java    From spring-cloud-contract with Apache License 2.0 4 votes vote down vote up
MessageRestController(RestTemplateBuilder restTemplateBuilder) {
	this.restTemplate = restTemplateBuilder.build();
}
 
Example 8
Source File: Application.java    From cloud-espm-cloud-native with Apache License 2.0 4 votes vote down vote up
/**
 * @param builder
 * @return RestTemplate
 */
@Bean
public RestTemplate rest(RestTemplateBuilder builder) {
  return builder.build();
}
 
Example 9
Source File: InternetHealthIndicator.java    From Spring-Boot-2.0-Projects with MIT License 4 votes vote down vote up
public InternetHealthIndicator(RestTemplateBuilder restTemplateBuilder) {
    this.restTemplate = restTemplateBuilder.build();
}
 
Example 10
Source File: ClientApp.java    From Mastering-Distributed-Tracing with MIT License 4 votes vote down vote up
@Bean
public RestTemplate restTemplate(RestTemplateBuilder restTemplateBuilder) {
    return restTemplateBuilder.build();
}
 
Example 11
Source File: DefaultRemoteGradleVersionResolver.java    From gradle-initializr with Apache License 2.0 4 votes vote down vote up
public DefaultRemoteGradleVersionResolver(RestTemplateBuilder restTemplateBuilder) {
    this.restTemplate = restTemplateBuilder.build();
}
 
Example 12
Source File: Frontend.java    From java-tutorial with Creative Commons Attribution Share Alike 4.0 International 4 votes vote down vote up
@Autowired Frontend(RestTemplateBuilder restTemplateBuilder) {
  this.restTemplate = restTemplateBuilder.build();
}
 
Example 13
Source File: ClientApplicationTests.java    From initializr with Apache License 2.0 4 votes vote down vote up
@Bean
RestTemplate restTemplate(RestTemplateBuilder builder) {
	return builder.build();
}
 
Example 14
Source File: LoanApplicationService.java    From spring-cloud-contract with Apache License 2.0 4 votes vote down vote up
@Autowired
public LoanApplicationService(RestTemplateBuilder builder) {
	this.restTemplate = builder.build();
}
 
Example 15
Source File: GitHubLookupService.java    From spring-boot-tutorial with Creative Commons Attribution Share Alike 4.0 International 4 votes vote down vote up
public GitHubLookupService(RestTemplateBuilder restTemplateBuilder) {
    this.restTemplate = restTemplateBuilder.build();
}
 
Example 16
Source File: CustomConfig.java    From spring-boot-tutorial with Creative Commons Attribution Share Alike 4.0 International 4 votes vote down vote up
@Bean
public RestTemplate restTemplate(RestTemplateBuilder builder) {
    return builder.build();
}
 
Example 17
Source File: UserServiceClient.java    From spring-microservice-sample with GNU General Public License v3.0 4 votes vote down vote up
public UserServiceClient(RestTemplateBuilder builder, ObjectMapper objectMapper) {
    this.restTemplate = builder.build();
    this.objectMapper = objectMapper;
}
 
Example 18
Source File: WebApiUserController.java    From syhthems-platform with MIT License 4 votes vote down vote up
public WebApiUserController(RestTemplateBuilder restTemplateBuilder, OAuthProperties oAuthProperties, SyhthemsProperties syhthemsProperties) {
    this.syhthemsProperties = syhthemsProperties;
    restTemplateBuilder.basicAuthentication(oAuthProperties.getClientId(), oAuthProperties.getClientSecret());
    this.restTemplate = restTemplateBuilder.build();
    this.oAuthProperties = oAuthProperties;
}
 
Example 19
Source File: CronosConfig.java    From yugastore-java with Apache License 2.0 4 votes vote down vote up
@Bean
public RestTemplate createRestTemplate(RestTemplateBuilder builder) {

	return builder.build();
}
 
Example 20
Source File: TMAutoConfiguration.java    From tx-lcn with Apache License 2.0 4 votes vote down vote up
@Bean
public RestTemplate restTemplate(RestTemplateBuilder restTemplateBuilder) {
    return restTemplateBuilder.build();
}