Tomcat:从元素' packageScan'开始发现无效内容。

时间:2015-10-22 20:27:14

标签: eclipse spring xsd tomcat7 apache-camel

我正在创建以下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:   来自类路径资源的XML文档中的第23行   [META-INF / spring / my-route.xml]无效;嵌套异常是   org.xml.sax.SAXParseException; lineNumber:23; columnNumber:20;   cvc-complex-type.2.4.a:找到无效的内容   元素&#39; packageScan&#39;。之一   &#39; {&#34; http://camel.apache.org/schema/spring&#34;:onException的,   &#34; http://camel.apache.org/schema/spring&#34;:onCompletion,   &#34; http://camel.apache.org/schema/spring&#34;:截距,   &#34; http://camel.apache.org/schema/spring&#34;:interceptFrom,   &#34; http://camel.apache.org/schema/spring&#34;:interceptSendToEndpoint,   &#34; http://camel.apache.org/schema/spring&#34;:restConfiguration,   &#34; http://camel.apache.org/schema/spring&#34;:休息,   &#34; http://camel.apache.org/schema/spring&#34;:路线}&#39;是预期的。

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

1 个答案:

答案 0 :(得分:4)

订单很重要!! ..尝试重新排列标签,如下所示,它会起作用。

 <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。 (标签序列可以在这里标识)