Java Spring Jaxb2Marshaller外部绑定文件

Java Spring Jaxb2Marshaller外部绑定文件,java,spring,spring-mvc,jaxb,unmarshalling,Java,Spring,Spring Mvc,Jaxb,Unmarshalling,在Spring中,我将声明我的org.springframework.oxm.jaxb.Jaxb2Marshaller,但我还想声明一个外部绑定文件: <bean id="myMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller"> <property name="contextPath" value="com.path.to.pojos" /> <property name=

在Spring中,我将声明我的org.springframework.oxm.jaxb.Jaxb2Marshaller,但我还想声明一个外部绑定文件:

<bean id="myMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
    <property name="contextPath" value="com.path.to.pojos" />
    <property name="jaxbContextProperties">
        <util:map>
            <entry key="eclipselink.oxm.metadata-source">
                <list>
                    <value>com/path/to/schema/binding.xjb</value>
                </list>
            </entry>
        </util:map>
    </property>
    <property name="schema" value="classpath:com/path/to/schema/myService.xsd"/>
</bean>

com/path/to/schema/binding.xjb
我的绑定文件如下所示:

<jaxb:bindings version="1.0" 
    jaxb:version="2.0"
    xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
    xmlns:annox="http://annox.dev.java.net" 
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
    jaxb:extensionBindingPrefixes="xjc annox">

    <jaxb:bindings schemaLocation="myService.xsd" node="/xs:schema">

        <jaxb:globalBindings>
            <xjc:javaType name="java.util.Date" xmlType="xs:date"
            adapter="com.some.path.to.custom.adapter.DateAdapter" />
        </jaxb:globalBindings>

        <!-- More Declarations -->

        </jaxb:bindings>
    </jaxb:bindings>

此设置与XJC配合使用,可以从模式和外部绑定文件生成对象。但是我无法为我的Spring配置获得适当的设置。

我得到以下错误:

org.xml.sax.SAXParseException; lineNumber: 9; columnNumber: 77; unexpected     element (uri:"http://java.sun.com/xml/ns/jaxb", local:"bindings"). Expected elements are <{http://www.eclipse.org/eclipselink/xsds/persistence/oxm}xml-schema>,<{http://www.eclipse.org/eclipselink/xsds/persistence/oxm}xml-schema-type>,<{http://www.eclipse.org/eclipselink/xsds/persistence/oxm}xml-schema-types>,<{http://www.eclipse.org/eclipselink/xsds/persistence/oxm}xml-java-type-adapters>,<{http://www.eclipse.org/eclipselink/xsds/persistence/oxm}xml-registries>,<{http://www.eclipse.org/eclipselink/xsds/persistence/oxm}xml-enums>,<{http://www.eclipse.org/eclipselink/xsds/persistence/oxm}java-types>
org.xml.sax.SAXParseException;行号:9;栏目号:77;意外元素(uri:)http://java.sun.com/xml/ns/jaxb,本地:“绑定”)。预期的元素为,,,,,,
我被困在这个问题上了,我真的需要绑定文件与我的模式分开。我在网上找不到这种设置的任何示例,我希望有一个关于如何使用JaxB2Marshaller正确配置外部绑定文件的示例

如果我的问题不完整或需要更多信息,请告诉我

谢谢


据我所知,绑定文件仅在编译期间使用,用于从XML模式派生Java类。因此,在运行时在封送器上配置它是没有意义的。无论是春天还是JAXB都不会考虑。使用绑定文件可以配置的所有内容都已在
com.path.to.pojos.*
类中