java - beans.xml Spring CXF 中的奇怪验证错误

标签 java xml spring jboss cxf

目前正在使用 Spring 开发 CXF。它返回此警告:

10:40:38,492 WARN  [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] (MSC service thread 1-2)
 Ignored XML validation warning: org.xml.sax.SAXParseException: schema_reference.4:
 Failed to read schema document 'http://cxf.apache.org/schemas/jaxrs.xsd', because 
1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.

然后它在启动时返回这个错误:

10:40:38,571 ERROR [org.springframework.web.context.ContextLoader] (MSC service thread 1-2) 
Context initialization failed: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:
 Line 14 in XML document from ServletContext resource [/WEB-INF/mvc-dispatcher-servlet.xml] 
is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c:
The matching wildcard is strict, but no declaration can be found for element 'jaxrs:server'.

这是我的 beans.xml:

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:jaxrs="http://cxf.apache.org/jaxrs"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans     
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context-3.0.xsd
         http://cxf.apache.org/jaxrs
         http://cxf.apache.org/schemas/jaxrs.xsd">

    <import resource="classpath:META-INF/cxf/cxf.xml" />
    <jaxrs:server id="myOrder" address="/">
            <jaxrs:servicebeans>
                <ref bean="orderInfoImpl">
                </ref>
            </jaxrs:servicebeans>

        </jaxrs:server>
        <bean id="orderInfoImpl" class="com.example.rest.OrderInfoImpl">
        </bean>

    <context:component-scan base-package="simpleclient, com.example.rest" />

    <bean
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix">
            <value>/WEB-INF/</value>
        </property>
        <property name="suffix">
            <value>.jsp</value>
        </property>
    </bean>
</beans>

最佳答案

能够通过添加正确的 jar 来解决这个问题,显然,jboss 7 有它自己的现成的 cxf jar ,但是我在我的应用程序中使用的 jar 是不同的版本。我只是匹配了 jar 并且它起作用了,还在 classpath/pom.xml 中排除了 jetty 。

关于java - beans.xml Spring CXF 中的奇怪验证错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18265032/

相关文章:

java - 未找到带有 URI 调度程序错误的 HTTP 请求的映射

java - Travis CI 使用错误的 Java 版本

java - WebDriver.findElements 抛出 InvalidElementStateException

Java Core 不包含 Native 内存部分

python - Python 和 XML 错误

html - 如何将 Scrapy XPath 与 XML 命名空间一起使用?

spring - 如何在 r2dbc-postgresql 中使用 EnumCodec

java - IntelliJ IDEA 丢失了我的依赖项的类路径

java - 以特定数字为增量生成双随机数

java - 如何使用 Java 或 pellet 将 SWRL 规则添加到本体中?