pTrik
pTrik

Reputation: 503

Configure bean RestTemplate in Spring Boot

is there way to add http message converter to RestTemplate in Spring Boot by configuration?

I would like to just add new message converted and do not remove the existing ones.

This will remove existing one.

@Bean
RestTemplate restTemplate(ProtobufHttpMessageConverter hmc) {
  return new RestTemplate(Arrays.asList(hmc));
}

Upvotes: 1

Views: 1568

Answers (1)

Andy Wilkinson
Andy Wilkinson

Reputation: 116311

You can add an extra converter like this:

RestTemplate restTemplate = new RestTemplate();
restTemplate.getMessageConverters().add(hmc);

Upvotes: 2

Related Questions