2015-10-14 22 views
0

如何使用正則表達式與SpEL?使用SpEl的正則表達式

想要追加系統屬性以及SpEL和正則表達式。

預期輸出:devInmessagebase/devInmessagetest/devInmessagesample

dev的: 'ENV' 可變

Inmessage:從屬性文件(in.topic.mesge)

星號(*):鹼/測試/樣本(任何作爲後綴)

試圖如下和許多其他方式,但不work.any建議?

<int-kafka:consumer-configuration group-id="default3" value-decoder="kafkaSpecificDecoder" 
      key-decoder="kafkaReflectionDecoder" max-messages="10"> 
      <int-kafka:topic-filter pattern="${systemProperties['env'] + in.topic.mesge.'*'}" streams="4" exclude="false" /> </int-kafka:consumer-configuration> 

回答

0

pattern屬性的正確語法是:

pattern="#{systemProperties['env'] + '${in.topic.mesge}' + '.*'}" 
+0

嗨@Garry羅素, 感謝以下錯誤reply.getting。 嵌套的異常是org.springframework.beans.factory.BeanCreationException:創建名爲'(內部bean)#43c0b942'的bean時出錯:bean實例化失敗;嵌套異常是org.springframework.beans.BeanInstantiationException:無法實例化bean類[org.springframework.integration.kafka.support.TopicFilterConfiguration]:構造函數拋出異常;嵌套異常是java.lang.RuntimeException:dev $ {in.topic.mesge}。*是一個無效的正則表達式。 – sam

+0

您需要一個''來添加一個配置器來解析佔位符。它需要指向你的屬性文件。 –

+0

我有屬性文件in place.if我只提到 sam