添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

No converter found capable of converting from type [java.lang.String] to type [org.springframework.expression.Expression] #2189

Closed
@mmaeller

Description

As far as I can track the issue down, due the commit for #2165 a regression has been created for issue #1979 .
I cannot start the application using a producer based expression property like 'routingKeyExpression' or 'delayExpression'.
If I comment them out, the application starts properly.

To Reproduce

spring:
  cloud:
    stream:
      bindings:
        inputMail:
          destination: ${rabbitmq.mail.exchange}
          group: ${rabbitmq.mail.queue}
          binder: rabbitMail
          consumer:
            maxAttempts: 1
        retryMail:
          destination: ${rabbitmq.mail.exchange}
          binder: rabbitMail
        dlqMail:
          destination: ${rabbitmq.mail.dlx}
          binder: rabbitMail
      binders:
        rabbitMail:
          type: rabbitMail
          environment:
            spring:
              cloud:
                stream:
                  rabbit:
                    bindings:
                      inputMail:
                        consumer:
                          autoBindDlq: true
                          queueNameGroupOnly: true
                          exchangeAutoDelete: false
                          deadLetterExchange: ${rabbitmq.mail.dlx}
                          delayedExchange: true
                      retryMail:
                        producer:
                          declareExchange: false
                          exchangeAutoDelete: false
                          delayExpression: 300000 # 5min
                      dlqMail:
                        producer:
                          declareExchange: false
                          exchangeAutoDelete: false
                          routingKeyExpression: '''${rabbitmq.mail.queue}'''

Version of the framework
3.1.3 (Spring cloud dependencies 2020.0.3)
Spring Boot 2.4.5 and also with 2.4.7
Expected behavior
Configuration works as in 3.1.2 (Spring cloud dependencies 2020.0.2)

The property will be resolved properly, but the application cannot start.
Error message

Failed to bind properties under 'spring.cloud.stream.rabbit.bindings.dlqMail.producer.routing-key-expression' to org.springframework.expression.Expression: Property: spring.cloud.stream.rabbit.bindings.dlqMail.producer.routing-key-expression Value: 'mail-local' Origin: "spring.cloud.stream.rabbit.bindings.dlqMail.producer.routingKeyExpression" from property source "rabbitMail" Reason: No converter found capable of converting from type [java.lang.String] to type [org.springframework.expression.Expression]