我在属性文件中有一个密码

com.password=$&m


它正在通过{{com.password}}插入到sftp骆驼路由中,而我正在获得"Unknown parameters=[{m=}]"

&被错误解释。
我已经尝试了一些方法,但是在文档中找不到任何内容。如何使它逐字使用密码?

编辑:

<cm:property-placeholder id="blueprint.placeholder" persistent-id="com.props" >
</cm:property-placeholder>


路线:

<camel:route id="uploadqueue">
    <camel:from uri="file://{{com.dir}}/?antInclude=*.xml&amp;delay=10000&amp;move=processed/${file:name}&amp;moveFailed=error/${file:name}" />
    <camel:to uri="log:input?showAll=true&amp;level=INFO"/>
    <camel:to uri="sftp://192.168.0.1/?username={{com.user}}&amp;password={{com.password}}" />
</camel:route>


编辑:
立即路线:

 <camel:to uri="sftp://192.168.0.1/?username={{com.user}}&amp;password=RAW({{com.password}})" />


堆栈跟踪。为保密起见略作编辑,但基本上是这样。
$&m的密码被解释为$的HTML(%24),密码,&表示为&语义和,而m则作为新参数。即RAW()什么也没做。

Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: sftp://192.168.0.1/?password=%24&m=&username=USERNAME due to: There are 1 parameters that couldn't be set on the endpoint. Check the uri if the parameters are spelt correctly and that they are properties of the endpoint. Unknown parameters=[{m=}]
    at org.apache.camel.impl.DefaultComponent.validateParameters(DefaultComponent.java:215) ~[?:?]
    at org.apache.camel.impl.DefaultComponent.createEndpoint(DefaultComponent.java:139) ~[?:?]
    at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:711) ~[?:?]
    at org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:80) ~[?:?]
    at org.apache.camel.model.RouteDefinition.resolveEndpoint(RouteDefinition.java:219) ~[?:?]
    at org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:115) ~[?:?]
    at org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:121) ~[?:?]
    at org.apache.camel.model.SendDefinition.resolveEndpoint(SendDefinition.java:62) ~[?:?]
    at org.apache.camel.model.SendDefinition.createProcessor(SendDefinition.java:56) ~[?:?]
    at org.apache.camel.model.ProcessorDefinition.makeProcessorImpl(ProcessorDefinition.java:562) ~[?:?]
    at org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:523) ~[?:?]
    at org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:239) ~[?:?]
    at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1300) ~[?:?]
    ... 26 more

最佳答案

根据documentation,这应该起作用。

<camel:to uri="sftp://192.168.0.1/?username={{com.user}}&amp;password=RAW({{com.password}})"

关于java - Camel 从属性文件中转义特殊字符,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/58323217/

10-08 21:46