Camel Rest DSL : property placeholder no longer works

时间:2019-04-08 13:39:07

标签: apache-camel spring-camel

I am currently migrating my applications from Spring Boot 1.5.19..RELEASE and Camel 2.18.3 to Spring Boot 2.1.4.RELEASE and Camel 2.23.1

For REST DSL, Camel property placeholder no longer seems to work and I am forced to go back to Spring placeholders.

I would like to point out, because it may not be clear, that the code works in the third case

    // SB. 1.5.19, camel 2.18.3 --> WORKS
    private void configureRestServices() {

        rest("{{rest.path.human-resources-codes}}")
            .consumes(APPLICATION_JSON)
            ... 
            .to("{{uri.human-resources-codes.put}}");

    // SB. 2.1.4, camel 2.23.1 --> DOESN'T WORK
    private void configureRestServices() {

        rest("{{rest.path.human-resources-codes}}")
            .consumes(APPLICATION_JSON)
            ... 
            .to("{{uri.human-resources-codes.put}}");

    // SB. 2.1.4, camel 2.23.1 --> WORKS
    @Value(value = "${rest.path.human-resources-codes}")
    private String REST_ENDPOINT_HUMAN_RESOURCES_CODES;

    private void configureRestServices() {

        rest(REST_ENDPOINT_HUMAN_RESOURCES_CODES)
            .consumes(APPLICATION_JSON)
            ... 
            .to("{{uri.human-resources-codes.put}}"); // this one still works.

EDIT

Positive matches:
-----------------

   ConfigServiceBootstrapConfiguration#configServicePropertySource matched:
      - @ConditionalOnProperty (spring.cloud.config.enabled) matched (OnPropertyCondition)
      - @ConditionalOnMissingBean (types: org.springframework.cloud.config.client.ConfigServicePropertySourceLocator; SearchStrategy: all) did not find any beans (OnBeanCondition)

   ConfigurationPropertiesRebinderAutoConfiguration matched:
      - @ConditionalOnBean (types: org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor; SearchStrategy: all) found bean 'org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor' (OnBeanCondition)

   ConfigurationPropertiesRebinderAutoConfiguration#configurationPropertiesBeans matched:
      - @ConditionalOnMissingBean (types: org.springframework.cloud.context.properties.ConfigurationPropertiesBeans; SearchStrategy: current) did not find any beans (OnBeanCondition)

   ConfigurationPropertiesRebinderAutoConfiguration#configurationPropertiesRebinder matched:
      - @ConditionalOnMissingBean (types: org.springframework.cloud.context.properties.ConfigurationPropertiesRebinder; SearchStrategy: current) did not find any beans (OnBeanCondition)

   EncryptionBootstrapConfiguration matched:
      - @ConditionalOnClass found required class 'org.springframework.security.crypto.encrypt.TextEncryptor' (OnClassCondition)

   PropertyPlaceholderAutoConfiguration#propertySourcesPlaceholderConfigurer matched:
      - @ConditionalOnMissingBean (types: org.springframework.context.support.PropertySourcesPlaceholderConfigurer; SearchStrategy: current) did not find any beans (OnBeanCondition)

EDIT (2)

Caused by: java.lang.IllegalArgumentException: PropertiesComponent with name properties must be defined in CamelContext to support property placeholders. 
Property with key [rest.path.human-resources-codes] not found in properties from text: {{{rest.path.human-resources-codes}}}
    at org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.getPropertyValue(DefaultPropertiesParser.java:271) ~[camel-core-2.23.1.jar:2.23.1]
    at org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.readProperty(DefaultPropertiesParser.java:157) ~[camel-core-2.23.1.jar:2.23.1]
    at org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.doParse(DefaultPropertiesParser.java:116) ~[camel-core-2.23.1.jar:2.23.1]
    at org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.parse(DefaultPropertiesParser.java:100) ~[camel-core-2.23.1.jar:2.23.1]
    at org.apache.camel.component.properties.DefaultPropertiesParser.parseUri(DefaultPropertiesParser.java:63) ~[camel-core-2.23.1.jar:2.23.1]
    at org.apache.camel.component.properties.PropertiesComponent.parseUri(PropertiesComponent.java:235) ~[camel-core-2.23.1.jar:2.23.1]
    at org.apache.camel.component.properties.PropertiesComponent.parseUri(PropertiesComponent.java:178) ~[camel-core-2.23.1.jar:2.23.1]
    at org.apache.camel.impl.DefaultCamelContext.resolvePropertyPlaceholders(DefaultCamelContext.java:2547) ~[camel-core-2.23.1.jar:2.23.1]
    at org.apache.camel.model.rest.RestDefinition.addRouteDefinition(RestDefinition.java:959) ~[camel-core-2.23.1.jar:2.23.1]

0 个答案:

没有答案