本文介绍了如何通过XML在Spring bean中设置Jaxb2Marshaller XmlAdapter列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Spring-WS中定义一个 Jaxb2Marshaller bean,以使用扩展 XmlAdapter 的自定义适配器。我在XML文件中有以下内容:

I'm trying to define a Jaxb2Marshaller bean in Spring-WS to use a custom adapter that extends XmlAdapter. I have the following in an XML file:

<bean id="jaxb2Marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
    <property name="classesToBeBound">
        <list>
            <!-- various classes to be bound... -->
        </list>
    </property>
    <property name="schema" value="myschema.xsd" />
    <property name="adapters">
        <list>
            <value>com.lmig.am.claims.clip.ContactAdapter</value>
        </list>
    </property>
</bean>

但是,我收到以下错误:

However, I'm getting the following error:

无法将[java.lang.String]类型的值转换为属性adapters [0]所需的类型[javax.xml.bind.annotation.adapters.XmlAdapter]:没有匹配的编辑器或转换策略

任何想法我做错了什么?谢谢!

Any ideas what I'm doing wrong? Thanks!

推荐答案

adapters属性需要一个XMLAdapter对象数组而不是Classes。所以正确的配置如下。

The adapters property is expecting an array of XMLAdapter objects not Classes. So the correct configuration is as follows.

<property name="adapters">
   <list>
         <bean class="com.lmig.am.claims.clip.ContactAdapter"/>
   </list>
</property>

这篇关于如何通过XML在Spring bean中设置Jaxb2Marshaller XmlAdapter列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 00:28