gpt4 book ai didi

java - Camel 从属性文件中转义特殊字符

转载 作者:行者123 更新时间:2023-12-02 09:26:13 26 4
gpt4 key购买 nike

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

com.password=$&m

它正在使用 {{com.password}} 插入 sftp Camel 路由,我收到 “未知参数=[{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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com