XML should be readable for humans. Therefore you will have to print XML output with correct indentation and line breaks.

JAXB is not doing so by default, also not using Spring.

In order to enable so called pretty printing for XML files generated using JAXB, you will have to modify the context.xml in your Java Spring project.