【问题标题】:How to set Jaxb2Marshaller list of XmlAdapters in Spring bean through XML?如何通过 XML 在 Spring bean 中设置 Jaxb2Marshaller 的 XmlAdapters 列表?
【发布时间】:2011-10-11 00:03:52
【问题描述】:

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

<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>

但是,我收到以下错误:

Cannot convert value of type [java.lang.String] to required type [javax.xml.bind.annotation.adapters.XmlAdapter] for property 'adapters[0]': no matching editors or conversion strategy found

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

【问题讨论】:

    标签: xml spring jaxb spring-ws jaxb2


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-03-12
      • 1970-01-01
      • 1970-01-01
      • 2012-09-21
      • 1970-01-01
      • 2015-04-28
      • 2023-02-06
      • 1970-01-01
      相关资源
      最近更新 更多