Spring 集成:使用引用而不是值作为属性?
Spring integration: Using a reference instead of a value as an attribute?
这是我希望成为 MQTT 消息驱动的通道适配器的片段。
我想要的是 "topics" 属性获取 presenceTopic 的值。
如何设置 "topics" 属性以使其使用 "presenceTopic" 作为参考而不是值?
<util:constant id="presenceTopic" static-field="blah blah"/>
<int-mqtt:message-driven-channel-adapter id="mqttInbound"
channel="inChannel"
client-id="blah blah"
url="${MQTT_URL}"
topics="__??__"
client-factory="clientFactory"/>
您需要学习 Spring 表达式语言和 Spring 功能才能在 beans 初始化期间使用它:
topics="#{presenceTopic}"
这真的要引用bean了。
参考手册中有更多信息:
https://docs.spring.io/spring/docs/5.0.7.RELEASE/spring-framework-reference/core.html#expressions
这是我希望成为 MQTT 消息驱动的通道适配器的片段。
我想要的是 "topics" 属性获取 presenceTopic 的值。
如何设置 "topics" 属性以使其使用 "presenceTopic" 作为参考而不是值?
<util:constant id="presenceTopic" static-field="blah blah"/>
<int-mqtt:message-driven-channel-adapter id="mqttInbound"
channel="inChannel"
client-id="blah blah"
url="${MQTT_URL}"
topics="__??__"
client-factory="clientFactory"/>
您需要学习 Spring 表达式语言和 Spring 功能才能在 beans 初始化期间使用它:
topics="#{presenceTopic}"
这真的要引用bean了。
参考手册中有更多信息:
https://docs.spring.io/spring/docs/5.0.7.RELEASE/spring-framework-reference/core.html#expressions