Sayi / swagger-dubbo

:page_with_curl: Dubbo的Swagger服务文档
Apache License 2.0
330 stars 186 forks source link

集成spring boot + dubbo #21

Closed liliang8858 closed 6 years ago

liliang8858 commented 6 years ago

报错: 什么原因 org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find

Sayi commented 6 years ago

可以把具体错误发出来,考虑配置下spring json convertor.

liliang8858 commented 6 years ago

请求 406

liliang8858 commented 6 years ago

已经解决 谢谢 方法: 1.继承 extends WebMvcConfigurerAdapter 2.覆盖方法: `@Override public void configureMessageConverters(List<HttpMessageConverter<?>> converters) { super.configureMessageConverters(converters); //1.需要定义一个convert转换消息的对象; FastJsonHttpMessageConverter fastJsonHttpMessageConverter = new FastJsonHttpMessageConverter(); //2.添加fastJson的配置信息,比如:是否要格式化返回的json数据; FastJsonConfig fastJsonConfig = new FastJsonConfig(); fastJsonConfig.setSerializerFeatures(SerializerFeature.PrettyFormat); //3处理中文乱码问题 List fastMediaTypes = new ArrayList<>(); fastMediaTypes.add(MediaType.APPLICATION_JSON_UTF8); //4.在convert中添加配置信息. fastJsonHttpMessageConverter.setSupportedMediaTypes(fastMediaTypes); fastJsonHttpMessageConverter.setFastJsonConfig(fastJsonConfig); //5.将convert添加到converters当中. converters.add(fastJsonHttpMessageConverter);

// converters.add(responseBodyConverter()); }`