How to set Jaxb2Marshaller list of XmlAdapters in Spring bean through XML?

╄→尐↘猪︶ㄣ 提交于 2019-12-10 13:27:11

问题


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:

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

Any ideas what I'm doing wrong? Thanks!


回答1:


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>


来源:https://stackoverflow.com/questions/7720031/how-to-set-jaxb2marshaller-list-of-xmladapters-in-spring-bean-through-xml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!