Bird
0
0

How can you configure Spring Boot to use XML instead of JSON for message serialization in REST APIs?

hard📝 Application Q9 of 15
Spring Boot - Messaging
How can you configure Spring Boot to use XML instead of JSON for message serialization in REST APIs?
AUse @XmlRootElement annotation on classes only
BAdd Jackson XML dependency and configure message converters
CSet application.properties with spring.serialization.format=xml
DAnnotate controller methods with @ResponseXml
Step-by-Step Solution
Solution:
  1. Step 1: Understand default serialization format

    Spring Boot uses JSON by default with Jackson library.
  2. Step 2: Enable XML serialization

    Adding Jackson XML dependency and configuring message converters enables XML support.
  3. Final Answer:

    Add Jackson XML dependency and configure message converters -> Option B
  4. Quick Check:

    XML support needs dependency and converter config [OK]
Quick Trick: Add Jackson XML and configure converters for XML [OK]
Common Mistakes:
  • Assuming @XmlRootElement alone enables XML serialization
  • Looking for non-existent spring.serialization.format property
  • Using unsupported @ResponseXml annotation

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes