@@ -1154,9 +1154,15 @@ tend to send accept headers that prefer XML.
1154
1154
1155
1155
[[howto-write-an-xml-rest-service]]
1156
1156
=== Write an XML REST Service
1157
- If you have the Jackson XML extension (`jackson-dataformat-xml`) on the classpath, you
1157
+ If you have the Jackson XML extension (`jackson-dataformat-xml`) or JAXB on the classpath, you
1158
1158
can use it to render XML responses. The previous example that we used for JSON would
1159
- work. To use the Jackson XML renderer, add the following dependency to your project:
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:
1160
1166
1161
1167
[source,xml,indent=0,subs="verbatim,quotes,attributes"]
1162
1168
----
@@ -1166,8 +1172,9 @@ work. To use the Jackson XML renderer, add the following dependency to your proj
1166
1172
</dependency>
1167
1173
----
1168
1174
1169
- If Jackson's XML extension is not available, JAXB (provided by default in the JDK) is
1170
- used, with the additional requirement of having `MyThing` annotated as
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
1171
1178
`@XmlRootElement`, as shown in the following example:
1172
1179
1173
1180
[source,java,indent=0,subs="verbatim,quotes,attributes"]
@@ -1179,9 +1186,15 @@ used, with the additional requirement of having `MyThing` annotated as
1179
1186
}
1180
1187
----
1181
1188
1182
- To get the server to render XML instead of JSON, you might have to send an
1183
- `Accept: text/xml` header (or use a browser).
1189
+ To use JAXB as XML renderer, add the following dependency to your project:
1184
1190
1191
+ [source,xml,indent=0,subs="verbatim,quotes,attributes"]
1192
+ ----
1193
+ <dependency>
1194
+ <groupId>org.glassfish.jaxb</groupId>
1195
+ <artifactId>jaxb-runtime</artifactId>
1196
+ </dependency>
1197
+ ----
1185
1198
1186
1199
1187
1200
[[howto-customize-the-jackson-objectmapper]]
0 commit comments