springMVC 整合camel-ftp启动时报错

唐小明生 发布于 2015/04/28 09:25
阅读 1K+
收藏 1

我的代码在

https://github.com/winfan/springMVC-camel-ftp


org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath*:spring-core.xml]
Offending resource: ServletContext resource [/WEB-INF/spring-servlet.xml]; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from relative location [spring-ftp.xml]
Offending resource: URL [file:/D:/Intellij_IDEA_project/java/upgrade/target/upgrade-web/WEB-INF/classes/spring-core.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Failed to create the JAXB binder; nested exception is javax.xml.bind.JAXBException: Provider com.sun.xml.bind.v2.ContextFactory could not be instantiated: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions
Two classes have the same XML type name "{http://camel.apache.org/schema/spring}propertyDefinition". Use @XmlType.name and @XmlType.namespace to assign different names to them.
this problem is related to the following location:
at org.apache.camel.model.config.PropertyDefinition
at private java.util.List org.apache.camel.model.config.PropertiesDefinition.properties
at org.apache.camel.model.config.PropertiesDefinition
at private org.apache.camel.model.config.PropertiesDefinition org.apache.camel.spring.CamelContextFactoryBean.properties
at org.apache.camel.spring.CamelContextFactoryBean
this problem is related to the following location:
at org.apache.camel.model.PropertyDefinition
at private java.util.List org.apache.camel.model.PropertiesDefinition.properties
at org.apache.camel.model.PropertiesDefinition
Two classes have the same XML type name "{http://camel.apache.org/schema/spring}propertiesDefinition". Use @XmlType.name and @XmlType.namespace to assign different names to them.
this problem is related to the following location:
at org.apache.camel.model.config.PropertiesDefinition
at private org.apache.camel.model.config.PropertiesDefinition org.apache.camel.spring.CamelContextFactoryBean.properties
at org.apache.camel.spring.CamelContextFactoryBean
this problem is related to the following location:
at org.apache.camel.model.PropertiesDefinition

加载中
0
唐小明生
唐小明生
在pom.xml加了一下依懒即可
<dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-core</artifactId>
            <version>2.15.1</version>
        </dependency>

        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-spring</artifactId>
            <version>2.15.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-ftp</artifactId>
            <version>2.15.1</version>
        </dependency>



在resources目录 下加入以下xml文件

spring-camel.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       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">

    <camelContext id="testCamelContext" xmlns="http://camel.apache.org/schema/spring">
        <package>com.xxxx.camel</package>
    </camelContext>

    <!-- enable Spring @Component scan -->
   <!-- <context:component-scan base-package="com.xxxx.camel"/>-->

    <camelContext xmlns="http://camel.apache.org/schema/spring">
        <!-- and then let Camel use those @Component scanned route builders -->
        <contextScan/>
    </camelContext>

    <!-- Let Spring create the Camel context and the Camel template, including lifecycle management such as starting and stopping them -->
   <!-- <camel:camelContext id="camelContext">
        <camel:template id="camelTemplate" />
    </camel:camelContext>-->

    <!-- Use Spring component scan to find the FtpSenderImpl implementation -->
    <!-- <context:component-scan base-package="com.xxxx.service.*" />-->
    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
    <camelContext xmlns="http://camel.apache.org/schema/spring">
        <template id="camelTemplate"/>
        <route>
            <from uri="file:D:/Intellij_IDEA_project/java/xxxx/src/main/webapp/upload"/>
            <to uri="ftp://bbbb@localhost/testjava?password=111111&amp;passiveMode=true"/>
            <to uri="ftp://aaaaa@localhost2/testjava?password=222222&amp;passiveMode=true"/>
        </route>
    </camelContext>

 <!--   <bean id="myConfig" class="org.apache.commons.net.ftp.FTPClientConfig">
        <property name="lenientFutureDates" value="true"/>
        <property name="serverLanguageCode" value="zh"/>
    </bean>-->

<!--    <camelContext id="camel5" xmlns="http://camel.apache.org/schema/spring">
        <routeBuilder ref="myBuilder" />
    </camelContext>-->

  <!--  <bean id="myBuilder" class="com.xxxx.camel.FtpRouteBuilder"/>
-->

  <!--  &lt;!&ndash; we use the AntPathMatcherRemoteFileFilter to use ant paths for includes and exclude &ndash;&gt;
    <bean id="myAntFilter" class="org.apache.camel.component.file.AntPathMatcherGenericFileFilter">
        &lt;!&ndash; include any files in the sub folder that has day in the name &ndash;&gt;
        <property name="includes" value="**/subfolder/**/*day*"/>
        &lt;!&ndash; exclude all files with bad in name or .xml files. Use comma to separate multiple excludes &ndash;&gt;
        <property name="excludes" value="**/*bad*,**/*.xml"/>
    </bean>-->

</beans>






0
唐小明生
唐小明生

引用来自“唐小明生”的评论

在pom.xml加了一下依懒即可
<dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-core</artifactId>
            <version>2.15.1</version>
        </dependency>

        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-spring</artifactId>
            <version>2.15.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-ftp</artifactId>
            <version>2.15.1</version>
        </dependency>



在resources目录 下加入以下xml文件

spring-camel.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       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">

    <camelContext id="testCamelContext" xmlns="http://camel.apache.org/schema/spring">
        <package>com.xxxx.camel</package>
    </camelContext>

    <!-- enable Spring @Component scan -->
   <!-- <context:component-scan base-package="com.xxxx.camel"/>-->

    <camelContext xmlns="http://camel.apache.org/schema/spring">
        <!-- and then let Camel use those @Component scanned route builders -->
        <contextScan/>
    </camelContext>

    <!-- Let Spring create the Camel context and the Camel template, including lifecycle management such as starting and stopping them -->
   <!-- <camel:camelContext id="camelContext">
        <camel:template id="camelTemplate" />
    </camel:camelContext>-->

    <!-- Use Spring component scan to find the FtpSenderImpl implementation -->
    <!-- <context:component-scan base-package="com.xxxx.service.*" />-->
    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
    <camelContext xmlns="http://camel.apache.org/schema/spring">
        <template id="camelTemplate"/>
        <route>
            <from uri="file:D:/Intellij_IDEA_project/java/xxxx/src/main/webapp/upload"/>
            <to uri="ftp://bbbb@localhost/testjava?password=111111&amp;passiveMode=true"/>
            <to uri="ftp://aaaaa@localhost2/testjava?password=222222&amp;passiveMode=true"/>
        </route>
    </camelContext>

 <!--   <bean id="myConfig" class="org.apache.commons.net.ftp.FTPClientConfig">
        <property name="lenientFutureDates" value="true"/>
        <property name="serverLanguageCode" value="zh"/>
    </bean>-->

<!--    <camelContext id="camel5" xmlns="http://camel.apache.org/schema/spring">
        <routeBuilder ref="myBuilder" />
    </camelContext>-->

  <!--  <bean id="myBuilder" class="com.xxxx.camel.FtpRouteBuilder"/>
-->

  <!--  &lt;!&ndash; we use the AntPathMatcherRemoteFileFilter to use ant paths for includes and exclude &ndash;&gt;
    <bean id="myAntFilter" class="org.apache.camel.component.file.AntPathMatcherGenericFileFilter">
        &lt;!&ndash; include any files in the sub folder that has day in the name &ndash;&gt;
        <property name="includes" value="**/subfolder/**/*day*"/>
        &lt;!&ndash; exclude all files with bad in name or .xml files. Use comma to separate multiple excludes &ndash;&gt;
        <property name="excludes" value="**/*bad*,**/*.xml"/>
    </bean>-->

</beans>






上面route中写了两个to,表示监控upload目录 的文件,同时上传到两个ftp服务器中

camel 随spring启动而启动,可以设置延迟处理,

详见文档http://camel.apache.org/spring.html

OSCHINA
登录后可查看更多优质内容
返回顶部
顶部