【问题标题】:Tomcat: Invalid content was found starting with element 'packageScan'Tomcat:发现以元素“packageScan”开头的无效内容
【发布时间】:2016-01-22 06:24:52
【问题描述】:

我正在创建以下 Camel 配置:

<?xml version="1.0" encoding="UTF-8"?>

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

    <camelContext xmlns="http://camel.apache.org/schema/spring">

      <routeContextRef ref="DoItRoute"/>

      <onException id="OnException">
         <exception>java.sql.SQLException</exception>
         <exception>java.lang.Exception</exception>
         <redeliveryPolicy maximumRedeliveries="0" />
         <to id="ErrorProcessor"                                  uri="bean:errorProcessor"/>
      </onException>

      <packageScan>
         <package>com.myself.route.doit</package>
         <excludes>*ExcludeMe*</excludes>
      </packageScan>

    </camelContext>

</beans>

在 Eclipse 中,当我将鼠标悬停在 &lt;camelContext 上时,它会告诉我

Element : camelContext
Content Model : (routeContextRef? | onException? | packageScan?)*

所以我的配置似乎遵循架构。

但是,当我将它部署到 Tomcat 时,出现以下异常:

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: 来自类路径资源的 XML 文档中的第 23 行 [META-INF/spring/my-route.xml] 无效;嵌套异常是 org.xml.sax.SAXParseException;行号:23;列号:20; cvc-complex-type.2.4.a:发现无效内容以 元素'packageScan'。之一 '{"http://camel.apache.org/schema/spring":onException, "http://camel.apache.org/schema/spring":onCompletion, "http://camel.apache.org/schema/spring":拦截, "http://camel.apache.org/schema/spring":interceptFrom, "http://camel.apache.org/schema/spring":interceptSendToEndpoint, "http://camel.apache.org/schema/spring":restConfiguration, “http://camel.apache.org/schema/spring”:休息, "http://camel.apache.org/schema/spring":route}' 是预期的。

这里发生了什么? Eclipse 和 Tomcat 看不同的 XSD? 我该如何解决这个问题?

【问题讨论】:

    标签: eclipse spring xsd tomcat7 apache-camel


    【解决方案1】:

    顺序很重要!!..尝试重新排列标签如下,它会起作用。

     <camelContext xmlns="http://camel.apache.org/schema/spring">              
    
         <packageScan>
             <package>com.myself.route.doit</package>
             <excludes>*ExcludeMe*</excludes>
          </packageScan>
    
          <routeContextRef ref="DoItRoute"/>
    
          <onException id="OnException">
             <exception>java.sql.SQLException</exception>
             <exception>java.lang.Exception</exception>
             <redeliveryPolicy maximumRedeliveries="0" />
             <to id="ErrorProcessor"                                  uri="bean:errorProcessor"/>
          </onException>      
    
        </camelContext>
    

    @参考http://camel.apache.org/schema/spring/camel-spring-2.15.0.xsd。 (这里可以识别标签序列)

    【讨论】:

    • 你完全正确!我应该检查 XSD。谢谢一百万!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-18
    • 2013-05-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多