zilcuanu
zilcuanu

Reputation: 3715

spring boot rest does not support xml out of the box

Spring Boot with Web dependency pulls jackson library dependencies and supports the Json format out of the box. But when I try to fetch the data in the xml format by placing the Accept header to application/xml, I get 406. The issue is resolved by adding the jackson-dataformat-xml dependency.

My question are,

  1. Why does jackson-data-format-xml be added and why is this not supported out of the box.
  2. Isn't JAXB not part of standard JDK and take care of marshalling and unmarshalling out of the box instead on relying on other jar files?

Upvotes: 0

Views: 388

Answers (1)

Mike
Mike

Reputation: 5142

  1. Spring is opinionated in many ways, and only supporting JSON out of the box is one example of that. Not all developers will want XML support and so it is left as an optional dependency.

  2. JAXB was pulled from the normal JDK distribution in Java 9 in order to help make the core JDK less bloated. Again, the idea is to let developers opt in to the technologies they need instead of giving them everything by default.

Here's a little history of JAXB and the various Java versions: https://www.jesperdj.com/2018/09/30/jaxb-on-java-9-10-11-and-beyond/

Upvotes: 1

Related Questions