Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SpringBoot project return format is not json #31067

Closed
RealHeart opened this issue Apr 30, 2024 · 4 comments
Closed

SpringBoot project return format is not json #31067

RealHeart opened this issue Apr 30, 2024 · 4 comments

Comments

@RealHeart
Copy link

RealHeart commented Apr 30, 2024

Bug Report

For English only, other languages will not accept.

Before report a bug, make sure you have:

Please pay attention on issues you submitted, because we maybe need more details.
If no response anymore and we cannot reproduce it on current information, we will close it.

Please answer these questions before submitting your issue. Thanks!

Which version of ShardingSphere did you use?

5.5.1-SNAPSHOT(d48a6c8)

Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?

ShardingSphere-JDBC

Expected behavior

return json

Actual behavior

return xml

Reason analyze (If you can)

shardingsphere-jdbc > shardingsphere-standalone-mode-repository-provider > jackson-dataformat-xml

Because jackson-dataformat-xml exists

Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.

Example codes for reproduce this issue (such as a github link).

@linghengqian
Copy link
Member

  • Why is the Expected behavior "return json"? You need to provide unit tests.

@RealHeart
Copy link
Author

  • Why is the Expected behavior "return json"? You need to provide unit tests.

Under normal circumstances, my API returns JSON, after introducing shardingsphere, because it contains jackson-dataformat-XML, Springboot will support returning XML-type content, the browser's accept content-type XML is higher than JSON, and the, this results in a preference for XML output, with the expectation of JSON, and my current solution is to change the default MediaType and skip the accept content-type detection to return the JSON format by default

@linghengqian
Copy link
Member

  • This is essentially one of the automatic configurations that spring boot does, and I recommend that you look for ways to define spring beans in the github issue area of spring boot to change the default configuration. The ShardingSphere uses jackson to parse xml for historical reasons, involving both spring boot and graalvm native image. Reference Removes use of JAXB API via jackson-dataformat-xml #29384 .

@linghengqian
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants