我们正在使用骆驼(2.6)将一些文件从一条路线复制到另一个路线。由于我们没有单元测试,我正在尝试编写一个新的,但我一直收到这个错误:
org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: sftp://admin@localhost/?connectTimeout=1800000&delay=1800000&disconnect=true&filter=%23myFileFilter&initialDelay=120000&passiveMode=true&password=admin&reconnectDelay=180000&recursive=true&useFixedDelay=true due to: Could not find a suitable setter for property: filter as there isn't a setter method with same type: java.lang.String nor type conversion possible: No type converter available to convert from type: java.lang.String to the required type: org.apache.camel.component.file.GenericFileFilter with value #myFileFilter
at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:449)
at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:463)
我粘贴我的代码:
<bean id="myFileFilter" class="com.my.test.RouteFileFilter">
<constructor-arg type="java.lang.String"
value="Regex_filter"/>
</bean>
RouteFilter 是 genericFileFilter 的一个实现
然后,在单元测试中我这样做:
CamelContext ctx = new DefaultCamelContext();
Exchange ex = new DefaultExchange(ctx);
Endpoint endpoint = new SftpEndpoint(sourceURI, new SftpComponent(), new SftpConfiguration());
ctx.addEndpoint(sourceURI, endpoint);
ctx.addRoutes(myBuilder);
ctx.start();
这是我得到错误的那一行:
getContext().getEndpoint(getSourceURIWithFilter(), GenericFileEndpoint.class).setProcessStrategy(new DefaultRouteFileProcessStrategy(this));