- 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()); }
推薦閱讀
- 信息系統(tǒng)與數(shù)據(jù)科學(xué)
- Architects of Intelligence
- SQL Server 2008數(shù)據(jù)庫(kù)應(yīng)用技術(shù)(第二版)
- 數(shù)據(jù)要素五論:信息、權(quán)屬、價(jià)值、安全、交易
- 數(shù)據(jù)驅(qū)動(dòng):從方法到實(shí)踐
- 大數(shù)據(jù)架構(gòu)和算法實(shí)現(xiàn)之路:電商系統(tǒng)的技術(shù)實(shí)戰(zhàn)
- Proxmox VE超融合集群實(shí)踐真?zhèn)?/a>
- SIEMENS數(shù)控技術(shù)應(yīng)用工程師:SINUMERIK 840D-810D數(shù)控系統(tǒng)功能應(yīng)用與維修調(diào)整教程
- R Machine Learning Essentials
- Node.js High Performance
- Scratch 2.0 Game Development HOTSHOT
- 數(shù)字化轉(zhuǎn)型實(shí)踐:構(gòu)建云原生大數(shù)據(jù)平臺(tái)
- 領(lǐng)域驅(qū)動(dòng)設(shè)計(jì)精粹
- 數(shù)據(jù)可視化五部曲
- Hands-On Java Deep Learning for Computer Vision