Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用<;在Spring3配置文件中指定模式验证;oxm:jaxb2-marshaller>;元素?_Spring_Jaxb - Fatal编程技术网

如何使用<;在Spring3配置文件中指定模式验证;oxm:jaxb2-marshaller>;元素?

如何使用<;在Spring3配置文件中指定模式验证;oxm:jaxb2-marshaller>;元素?,spring,jaxb,Spring,Jaxb,我选择在我的项目中使用Spring Jaxb2Marshaller来支持JAXB,但我无法在元素oxm:jaxb2 marshaller中指定模式文件,我只找到了一个contextPath属性,没有找到任何关于模式的内容 我必须使用旧的Jaxb2Marshaller配置样式(使用bean:bean元素) 类Jaxb2Marshaller具有模式属性,请尝试此代码示例 <bean id="jaxbMarshaller" class="org.springframework.oxm.jaxb.

我选择在我的项目中使用Spring Jaxb2Marshaller来支持JAXB,但我无法在元素
oxm:jaxb2 marshaller
中指定模式文件,我只找到了一个contextPath属性,没有找到任何关于模式的内容


我必须使用旧的Jaxb2Marshaller配置样式(使用
bean:bean
元素)

Jaxb2Marshaller
具有模式属性,请尝试此代码示例

<bean id="jaxbMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
        <property name="classesToBeBound">
            <list>
                <value>my.package.ResponseObj</value>
            </list>
        </property>
        <!-- Possibly include schema for validation -->
        <property name="schema" value="classpath:schema.xsd"/>
</bean>

my.package.ResponseObj
编辑:
我认为您不能使用新的OXM应答器在配置文件中直接指定XML模式。中没有用于此的xml元素或属性。但是您可以直接在“classe to bind”中使用新的@XmlSchema注释。看看这个。

Jaxb2Marshaller
有一个schema属性,请尝试下面的代码示例

<bean id="jaxbMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
        <property name="classesToBeBound">
            <list>
                <value>my.package.ResponseObj</value>
            </list>
        </property>
        <!-- Possibly include schema for validation -->
        <property name="schema" value="classpath:schema.xsd"/>
</bean>

my.package.ResponseObj
编辑:
我认为您不能使用新的OXM应答器在配置文件中直接指定XML模式。中没有用于此的xml元素或属性。但是您可以直接在“classe to bind”中使用新的@XmlSchema注释。看看这个。

谢谢,您的解决方案非常好,但我想要的是oxm:jaxb2 marshaller配置样式,而不是旧样式。我在oxm:jaxb2-marshaller元素中找不到任何schema-config属性。谢谢,您的解决方案非常好,但我想要的是oxm:jaxb2-marshaller配置样式,而不是旧样式。我在oxm:jaxb2 marshaller元素中找不到任何schema-config属性。