- Spring Boot 2.0 Cookbook(Second Edition)
- Alex Antonov
- 118字
- 2021-06-24 19:24:41
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.
- Let's add ByteArrayHttpMessageConverter as @Bean to our WebConfiguration class in the following manner:
@Bean public ByteArrayHttpMessageConverter byteArrayHttpMessageConverter() { return new ByteArrayHttpMessageConverter(); }
- 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()); }
- 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()); }
推薦閱讀
- App+軟件+游戲+網(wǎng)站界面設(shè)計(jì)教程
- 企業(yè)大數(shù)據(jù)系統(tǒng)構(gòu)建實(shí)戰(zhàn):技術(shù)、架構(gòu)、實(shí)施與應(yīng)用
- R數(shù)據(jù)科學(xué)實(shí)戰(zhàn):工具詳解與案例分析(鮮讀版)
- Apache Kylin權(quán)威指南
- 達(dá)夢數(shù)據(jù)庫運(yùn)維實(shí)戰(zhàn)
- Splunk智能運(yùn)維實(shí)戰(zhàn)
- 從實(shí)踐中學(xué)習(xí)sqlmap數(shù)據(jù)庫注入測試
- Filecoin原理與實(shí)現(xiàn)
- 大數(shù)據(jù)技術(shù)體系詳解:原理、架構(gòu)與實(shí)踐
- 云原生架構(gòu):從技術(shù)演進(jìn)到最佳實(shí)踐
- ECharts數(shù)據(jù)可視化:入門、實(shí)戰(zhàn)與進(jìn)階
- 量化投資:交易模型開發(fā)與數(shù)據(jù)挖掘
- 實(shí)用預(yù)測分析
- Kafka權(quán)威指南(第2版)
- MySQL 8.0從入門到實(shí)戰(zhàn)