java - Camel 属性-占位符 : Not able to configure `camel:sslContextParameters` with nested properties

标签 java spring properties apache-camel

我正在使用 Camel-HTTP4 2.10.4 组件从我的应用程序调用远程 REST 服务。此通信需要 SSL 配置。我成功使用 resourcepassword 的硬编码值测试了我的配置。

现在我需要使用camel的Property-Placeholder进行相同的配置。我在 spring 配置中使用嵌套属性。例如:

${${env:${default.fallback.env}}.path.to.keystore} 

我关注了Using PropertyPlaceholder并定义

<bean id="bridgePropertyPlaceholder" class="org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer">
    <property name="locations">
        <list>
            <ref bean="confgPath1" />
            <ref bean="configPath2" />
        </list>
    </property>
</bean>

和sslContext参数如下

<camel:sslContextParameters id="sslContextParameters">
    <camel:trustManagers>
        <camel:keyStore resource="{{{{default.fallback.env}}.keystore.file}}"
            password="{{{{default.fallback.env}}.keystore.password}}" />
    </camel:trustManagers>
    <camel:keyManagers keyPassword="{{{{default.fallback.env}}.keystore.password}}">
        <camel:keyStore resource="{{{{default.fallback.env}}.keystore.file}}"
            password="{{{{default.fallback.env}}.keystore.password}}" />
    </camel:keyManagers>
    <camel:clientParameters>
        <camel:cipherSuitesFilter>
            <camel:include>.*</camel:include>
        </camel:cipherSuitesFilter>
    </camel:clientParameters>
</camel:sslContextParameters>

我的应用程序在启动时成功加载 spring 上下文。但到达端点后我收到错误:

Failed to resolve endpoint <<My remote service URL>> due to: Error parsing property value: {{{{default.fallback.env}}.keystore.password}}.

我可以使用 Camel 的属性占位符来表示简单的属性。例如

{{default.fallback.env}}

但是,当我尝试使用嵌套属性时,它给出了上述指定的错误。帮我找出解决这个问题的正确方法。

最佳答案

当前的camel属性组件不支持嵌套属性,所以我就填个JIRA为了它。

由于Camel属性首先不支持嵌套属性,因此您可以像这样定义属性文件,并从系统属性设置环境并使用{{someproperty}}来引用属性。

someproperty={{{{environment}}.someproperty}}

# LOCAL SERVER
junit.someproperty=junit

# LOCAL SERVER
local.someproperty=local

# TEST
test.someproperty=test

# PROD
prod.someproperty=prod

关于java - Camel 属性-占位符 : Not able to configure `camel:sslContextParameters` with nested properties,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22814272/

相关文章:

java - WebSphere Liberty Profile Verbose Class Logging - 它的输出在哪里?

java - 使用 GSON 给出的错误预期为 BEGIN_ARRAY,但实际为 STRING

java - bean类无效属性 'dao'的原因

javascript - x.y 和 x ['y' ] 是否会导致主机对象出现不同的行为?

java - JDBC Oracle 属性文件

java - 使用 SonarQube Jenkins Plung 从 Jenkins 中的 pom 文件派生强制 SonarQube 属性

Java字符集编码问题(从UTF8到cp866)

java - 在 Android 中将 double 转换为字符串

java - AOP 与 Spring 安全

spring - @Qualifier 和 @Resource 在 Spring 测试框架下运行测试用例时不起作用