Closed klzami closed 2 years ago
基于spring boot 1.5.x搭建demo项目并编写测试controller
访问该测试controller,默认返回json格式的response
引用以下包:
<dependency> <groupId>org.apache.dubbo</groupId> <artifactId>dubbo-spring-boot-starter</artifactId> <version>2.7.7</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.9.2</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>2.9.2</version> </dependency> <dependency> <groupId>io.swagger</groupId> <artifactId>swagger-jersey2-jaxrs</artifactId> <version>1.5.9</version> </dependency>
重启demo项目并再次访问测试controller,这时会返回xml格式的response
引用swagger不改变spring boot的默认http message converter组织方式,不影响各接口的response格式。
引用swagger后改变了spring boot的默认http message converter组织方式,进而改变了各接口的response格式。
io.swagger.jaxrs.listing.BaseApiListingResource
swagger-jersey2-jaxrs
jackson-dataformat-xml
XmlMapper
can you provide a recurring case for this issue. Thanks!
I think this is not a problem that dubbo needs to solve. You can try to specify application/json in the header and specify the http message in json format.
application/json
Environment
Steps to reproduce this issue
基于spring boot 1.5.x搭建demo项目并编写测试controller
访问该测试controller,默认返回json格式的response
引用以下包:
重启demo项目并再次访问测试controller,这时会返回xml格式的response
Expected Result
引用swagger不改变spring boot的默认http message converter组织方式,不影响各接口的response格式。
Actual Result
引用swagger后改变了spring boot的默认http message converter组织方式,进而改变了各接口的response格式。
Trouble Shooting
io.swagger.jaxrs.listing.BaseApiListingResource
。swagger-jersey2-jaxrs
包。swagger-jersey2-jaxrs
包引用了jackson-dataformat-xml
包。jackson-dataformat-xml
内部的XmlMapper
类会改变SpringBoot的HttpMessageConverter组装过程,从而改变默认response格式。