我的代码在
https://github.com/winfan/springMVC-camel-ftp
在resources目录下加入以下xml文件
spring-camel.xml
<?xmlversion="1.0"encoding="UTF-8"?><beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://camel.apache.org/schema/springhttp://camel.apache.org/schema/spring/camel-spring.xsd"><camelContextid="testCamelContext"xmlns="http://camel.apache.org/schema/spring"><package>com.xxxx.camel</package></camelContext><!--enableSpring@Componentscan--><!--<context:component-scanbase-package="com.xxxx.camel"/>--><camelContextxmlns="http://camel.apache.org/schema/spring"><!--andthenletCamelusethose@Componentscannedroutebuilders--><contextScan/></camelContext><!--LetSpringcreatetheCamelcontextandtheCameltemplate,includinglifecyclemanagementsuchasstartingandstoppingthem--><!--<camel:camelContextid="camelContext"><camel:templateid="camelTemplate"/></camel:camelContext>--><!--UseSpringcomponentscantofindtheFtpSenderImplimplementation--><!--<context:component-scanbase-package="com.xxxx.service.*"/>--><beanclass="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/><camelContextxmlns="http://camel.apache.org/schema/spring"><templateid="camelTemplate"/><route><fromuri="file:D:/Intellij_IDEA_project/java/xxxx/src/main/webapp/upload"/><touri="ftp://bbbb@localhost/testjava?password=111111&passiveMode=true"/><touri="ftp://aaaaa@localhost2/testjava?password=222222&passiveMode=true"/></route></camelContext><!--<beanid="myConfig"class="org.apache.commons.net.ftp.FTPClientConfig"><propertyname="lenientFutureDates"value="true"/><propertyname="serverLanguageCode"value="zh"/></bean>--><!--<camelContextid="camel5"xmlns="http://camel.apache.org/schema/spring"><routeBuilderref="myBuilder"/></camelContext>--><!--<beanid="myBuilder"class="com.xxxx.camel.FtpRouteBuilder"/>--><!--<!–weusetheAntPathMatcherRemoteFileFiltertouseantpathsforincludesandexclude–><beanid="myAntFilter"class="org.apache.camel.component.file.AntPathMatcherGenericFileFilter"><!–includeanyfilesinthesubfolderthathasdayinthename–><propertyname="includes"value="**/subfolder/**/*day*"/><!–excludeallfileswithbadinnameor.xmlfiles.Usecommatoseparatemultipleexcludes–><propertyname="excludes"value="**/*bad*,**/*.xml"/></bean>--></beans>在resources目录下加入以下xml文件
spring-camel.xml
<?xmlversion="1.0"encoding="UTF-8"?><beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://camel.apache.org/schema/springhttp://camel.apache.org/schema/spring/camel-spring.xsd"><camelContextid="testCamelContext"xmlns="http://camel.apache.org/schema/spring"><package>com.xxxx.camel</package></camelContext><!--enableSpring@Componentscan--><!--<context:component-scanbase-package="com.xxxx.camel"/>--><camelContextxmlns="http://camel.apache.org/schema/spring"><!--andthenletCamelusethose@Componentscannedroutebuilders--><contextScan/></camelContext><!--LetSpringcreatetheCamelcontextandtheCameltemplate,includinglifecyclemanagementsuchasstartingandstoppingthem--><!--<camel:camelContextid="camelContext"><camel:templateid="camelTemplate"/></camel:camelContext>--><!--UseSpringcomponentscantofindtheFtpSenderImplimplementation--><!--<context:component-scanbase-package="com.xxxx.service.*"/>--><beanclass="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/><camelContextxmlns="http://camel.apache.org/schema/spring"><templateid="camelTemplate"/><route><fromuri="file:D:/Intellij_IDEA_project/java/xxxx/src/main/webapp/upload"/><touri="ftp://bbbb@localhost/testjava?password=111111&passiveMode=true"/><touri="ftp://aaaaa@localhost2/testjava?password=222222&passiveMode=true"/></route></camelContext><!--<beanid="myConfig"class="org.apache.commons.net.ftp.FTPClientConfig"><propertyname="lenientFutureDates"value="true"/><propertyname="serverLanguageCode"value="zh"/></bean>--><!--<camelContextid="camel5"xmlns="http://camel.apache.org/schema/spring"><routeBuilderref="myBuilder"/></camelContext>--><!--<beanid="myBuilder"class="com.xxxx.camel.FtpRouteBuilder"/>--><!--<!–weusetheAntPathMatcherRemoteFileFiltertouseantpathsforincludesandexclude–><beanid="myAntFilter"class="org.apache.camel.component.file.AntPathMatcherGenericFileFilter"><!–includeanyfilesinthesubfolderthathasdayinthename–><propertyname="includes"value="**/subfolder/**/*day*"/><!–excludeallfileswithbadinnameor.xmlfiles.Usecommatoseparatemultipleexcludes–><propertyname="excludes"value="**/*bad*,**/*.xml"/></bean>--></beans>版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。