Tomcat: 发现以元素 'packageScan' 开头的无效内容

Tomcat: Invalid content was found starting with element 'packageScan'

我正在创建以下 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 中,当我将鼠标悬停在 <camelContext 上时,它告诉我

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

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

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

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 23 in XML document from class path resource [META-INF/spring/my-route.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 23; columnNumber: 20; cvc-complex-type.2.4.a: Invalid content was found starting with element 'packageScan'. One of '{"http://camel.apache.org/schema/spring":onException, "http://camel.apache.org/schema/spring":onCompletion, "http://camel.apache.org/schema/spring":intercept, "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":rest, "http://camel.apache.org/schema/spring":route}' is expected.

这是怎么回事? Eclipse 和Tomcat 看不同XSD 的? 我该如何解决这个问题?

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

 <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>

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