How to do it...

There are a number of ways in which we can configure converters. It all depends on which one you prefer or how much control you want to achieve.

  1. Let's add ByteArrayHttpMessageConverter as @Bean to our WebConfiguration class in the following manner:
@Bean 
public  
  ByteArrayHttpMessageConverter  
    byteArrayHttpMessageConverter() { 
  return new ByteArrayHttpMessageConverter(); 
} 
  1. Another way to achieve this is to override the configureMessageConverters method in the WebConfiguration class, which extends WebMvcConfigurerAdapter, defining such a method as follows:
@Override 
public void configureMessageConverters
(List<HttpMessageConverter<?>> converters) { converters.add(new ByteArrayHttpMessageConverter()); }
  1. If you want to have a bit more control, we can override the extendMessageConverters method in the following way:
@Override 
public void extendMessageConverters
(List<HttpMessageConverter<?>> converters) { converters.clear(); converters.add(new ByteArrayHttpMessageConverter()); }
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.31.209