D V*_*ria 3 spring apache-camel
我正在尝试创建使用Camel Spring将文件从一个位置移动到另一个位置的组件.
它适用于FTP,但在尝试使用SFTP时出错.
错误是(SFTP URI:sftp:// IP地址:端口/ CamelTesting?username = testftp&password = testftp): 从类路径资源加载XML bean定义[testApplicationContext.xml]线程"main"中的异常org.springframework.beans.factory .xml.XmlBeanDefinitionStoreException:来自类路径资源[processorApplicationContext.xml]的XML文档中的第25行无效; 嵌套异常是org.xml.sax.SAXParseException; lineNumber:25; columnNumber:76; 对实体"密码"的引用必须以";"结尾 分隔符.
错误是(SFTP URI(&):sftp:// IP地址:端口/ CamelTesting?username = testftp&password = testftp): 线程"main"中的异常org.apache.camel.RuntimeCamelException:org.apache.camel.FailedToCreateRouteException:Failed创建路由route1 at:>>> To [sftp:// IP Address:Port/CamelTesting?username = testftp&password = testftp] <<< in route:Route(route1)[[from [file:D:/ Test/in ]] - > [To [sftp:/ IP地址:端口...因为无法解析端点:sftp:// IP地址:端口/ CamelTesting?密码= testftp&username = testftp,原因是:找不到使用scheme的组件:sftp
依赖关系是:
<dependencies>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<version>2.15.1</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.1.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring</artifactId>
<version>2.15.1</version>
</dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud)
testApplicationContext.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 xmlns="http://camel.apache.org/schema/spring">
<!--FTP Working fine-->
<!--route>
<from uri="file:D:/Test/in" />
<to uri="file:D:/Test/out" />
</route-->
<!--SFTP-->
<route>
<from uri="file:D:/Test/in" />
<to uri="sftp://<IP Address:Port>/CamelTesting?username=testftp&password=testftp"/>
</route>
</camelContext>
Run Code Online (Sandbox Code Playgroud)
测试类:
import org.apache.camel.CamelContext;
import org.apache.camel.spring.SpringCamelContext;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class testSFTP {
public static final void main(String[] args) throws Exception {
ConfigurableApplicationContext appContext = new ClassPathXmlApplicationContext("testApplicationContext.xml");
CamelContext camelContext = SpringCamelContext.springCamelContext(appContext, false);
try {
camelContext.start();
Thread.sleep(3000);
}catch(Exception e){
e.printStackTrace();
}
finally {
camelContext.stop();
appContext.close();
}
}
}
Run Code Online (Sandbox Code Playgroud)
有人可以帮助我解决问题.
在xml中&用作&
<route>
<from uri="file:D:/Test/in" />
<to uri="sftp://<IP Address:Port>/CamelTesting?username=testftp&password=testftp"/>
</route>
Run Code Online (Sandbox Code Playgroud)
对于secord错误:
您需要将camel-ftp添加到类路径中.只需将其作为依赖项添加到pom.xml即可.
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-ftp</artifactId>
<version>2.15.1</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助.
| 归档时间: |
|
| 查看次数: |
5186 次 |
| 最近记录: |