167.2. Spring Boot Auto-Configuration
组件支持 16 个选项,如下所列。
| Name | 描述 | 默认值 | 类型 |
|---|---|---|---|
| camel.dataformat.jacksonxml.allow-jms-type | 用于 JMS 用户,以允许 JMS spec 中的 JMSType 标头指定一个 FQN 类名称来用于 unmarshal。 | false | 布尔值 |
| camel.dataformat.jacksonxml.allow-unmarshall-type | 如果启用,则允许 Jackson 在 unmarshalling 期间尝试使用 CamelJacksonUnmarshalType 标头。这只有在需要使用时才启用。 | false | 布尔值 |
| camel.dataformat.jacksonxml.collection-type-name | 引用要使用的自定义集合类型,以便在 registry 中查找。这个选项应该很少被使用,但允许使用与基于 java.util.Collection 不同的集合类型。 | 字符串 | |
| camel.dataformat.jacksonxml.content-type-header | 如果数据格式能够这样做,则数据格式是否应该使用 data 格式的类型设置 Content-Type 标头。例如,用于数据格式到 XML 的 application/xml 或用于数据格式的 application/json 发送到 JSon 等。 | false | 布尔值 |
| camel.dataformat.jacksonxml.disable-features | 在 Jackson com.fasterxml.jackson.databind.ObjectMapper 上禁用的功能集合。这个功能应该是与 com.fasterxml.jackson.databind.SerializationFeature, com.fasterxml.jackson.databind.DeserializationFeature, 或 com.fasterxml.jackson.databind.MapperFeature multiple features 分开的名称 | 字符串 | |
| camel.dataformat.jacksonxml.enable-features | 在 Jackson com.fasterxml.jackson.databind.ObjectMapper 上启用的功能集合。这个功能应该是与 com.fasterxml.jackson.databind.SerializationFeature, com.fasterxml.jackson.databind.DeserializationFeature, 或 com.fasterxml.jackson.databind.MapperFeature multiple features 分开的名称 | 字符串 | |
| camel.dataformat.jacksonxml.enable-jaxb-annotation-module | 在使用 jackson 时,是否启用 JAXB 注释模块。启用之后,Jackson 可以使用 JAXB 注释。 | false | 布尔值 |
| camel.dataformat.jacksonxml.enabled | 启用 jacksonxml dataformat | true | 布尔值 |
| camel.dataformat.jacksonxml.include | 如果您想 marshal a pojo to JSON,并且 pojo 具有一些带有 null 值的字段。如果您想要跳过这些 null 值,您可以将这个选项设置为 NON_NULL | 字符串 | |
| camel.dataformat.jacksonxml.json-view | 当 marshalling a POJO to JSON 时,您可能想要从 JSON 输出中排除某些字段。通过 Jackson,您可以使用 JSON 视图来实现此目的。此选项是引用具有 JsonView 注释的类 | 类 | |
| camel.dataformat.jacksonxml.module-class-names | 使用自定义 Jackson 模块 com.fasterxml.jackson.databind.Module 指定为 String with FQN 类名称。可以使用逗号分隔多个类。 | 字符串 | |
| camel.dataformat.jacksonxml.module-refs | 使用 Camel registry 中引用的自定义 Jackson 模块。可以使用逗号分隔多个模块。 | 字符串 | |
| camel.dataformat.jacksonxml.pretty-print | 要启用用户化的打印输出,请执行以下操作:默认为 false。 | false | 布尔值 |
| camel.dataformat.jacksonxml.unmarshal-type-name | 取消警报时要使用的 java 类型的类名称 | 字符串 | |
| camel.dataformat.jacksonxml.use-list | 要取消警报到映射列表或 Pojo 列表,请执行以下操作: | false | 布尔值 |
| camel.dataformat.jacksonxml.xml-mapper | 查找并使用给定 id 的现有 XmlMapper。 | 字符串 |
ND
167.2.1. 在 Spring DSL 中使用 Jackson XML 复制链接链接已复制到粘贴板!
在 Spring DSL 中使用 Data Format 时,您需要首先声明数据格式。这在 DataFormats XML 标签中完成。
<dataFormats>
<!-- here we define a Xml data format with the id jack and that it should use the TestPojo as the class type when
doing unmarshal. The unmarshalTypeName is optional, if not provided Camel will use a Map as the type -->
<jacksonxml id="jack" unmarshalTypeName="org.apache.camel.component.jacksonxml.TestPojo"/>
</dataFormats>
<dataFormats>
<!-- here we define a Xml data format with the id jack and that it should use the TestPojo as the class type when
doing unmarshal. The unmarshalTypeName is optional, if not provided Camel will use a Map as the type -->
<jacksonxml id="jack" unmarshalTypeName="org.apache.camel.component.jacksonxml.TestPojo"/>
</dataFormats>
然后您可以在路由中引用此 id:
<route>
<from uri="direct:back"/>
<unmarshal ref="jack"/>
<to uri="mock:reverse"/>
</route>
<route>
<from uri="direct:back"/>
<unmarshal ref="jack"/>
<to uri="mock:reverse"/>
</route>