Skip to content

Commit c47edd1

Browse files
committed
Polish "Update instructions on how to use JAXB as XML renderer"
Closes gh-16005
1 parent 221ff8d commit c47edd1

File tree

1 file changed

+11
-13
lines changed
  • spring-boot-project/spring-boot-docs/src/main/asciidoc

1 file changed

+11
-13
lines changed

spring-boot-project/spring-boot-docs/src/main/asciidoc/howto.adoc

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,15 +1154,9 @@ tend to send accept headers that prefer XML.
11541154

11551155
[[howto-write-an-xml-rest-service]]
11561156
=== Write an XML REST Service
1157-
If you have the Jackson XML extension (`jackson-dataformat-xml`) or JAXB on the classpath, you
1157+
If you have the Jackson XML extension (`jackson-dataformat-xml`) on the classpath, you
11581158
can use it to render XML responses. The previous example that we used for JSON would
1159-
work.
1160-
1161-
NOTE: To get the server to render XML instead of JSON, you might have to send an
1162-
`Accept: text/xml` header (or use a browser).
1163-
1164-
==== Jackson XML
1165-
To use the Jackson XML renderer, add the following dependency to your project:
1159+
work. To use the Jackson XML renderer, add the following dependency to your project:
11661160

11671161
[source,xml,indent=0,subs="verbatim,quotes,attributes"]
11681162
----
@@ -1172,10 +1166,9 @@ To use the Jackson XML renderer, add the following dependency to your project:
11721166
</dependency>
11731167
----
11741168

1175-
==== JAXB
1176-
If Jackson's XML extension is not available, JAXB is tried next,
1177-
with the additional requirement of having `MyThing` annotated as
1178-
`@XmlRootElement`, as shown in the following example:
1169+
If Jackson's XML extension is not available and JAXB is available, XML can be rendered
1170+
with the additional requirement of having `MyThing` annotated as `@XmlRootElement`, as
1171+
shown in the following example:
11791172

11801173
[source,java,indent=0,subs="verbatim,quotes,attributes"]
11811174
----
@@ -1186,7 +1179,8 @@ with the additional requirement of having `MyThing` annotated as
11861179
}
11871180
----
11881181

1189-
To use JAXB as XML renderer, add the following dependency to your project:
1182+
JAXB is only available out of the box with Java 8. If you're using a more recent java
1183+
generation, add the following dependency to your project:
11901184

11911185
[source,xml,indent=0,subs="verbatim,quotes,attributes"]
11921186
----
@@ -1196,6 +1190,10 @@ To use JAXB as XML renderer, add the following dependency to your project:
11961190
</dependency>
11971191
----
11981192

1193+
NOTE: To get the server to render XML instead of JSON, you might have to send an
1194+
`Accept: text/xml` header (or use a browser).
1195+
1196+
11991197

12001198
[[howto-customize-the-jackson-objectmapper]]
12011199
=== Customize the Jackson ObjectMapper

0 commit comments

Comments
 (0)