参考资料:No converter found for return value of type: class java.util.LinkedHashMap
解决方法:
/**
* @author stonelu
* @date 2019-09-27 18:19
*/
@Configuration
public class CustomMvcConfiguration extends WebMvcConfigurerAdapter {
@Bean
public HttpMessageConverter<String> responseBodyConverter() {
StringHttpMessageConverter converter = new StringHttpMessageConverter(Charset.forName("UTF-8"));
return converter;
}
@Override
public void configureMessageConverters( List<HttpMessageConverter<?>> converters) {
super.configureMessageConverters(converters);
// 接口返回值:
// string对象
converters.add(responseBodyConverter());
// json对象
converters.add(new MappingJackson2HttpMessageConverter());
}
}