配置中的Spring注释值 [英] Spring annotation value from configuration
本文介绍了配置中的Spring注释值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的Spring Boot应用程序中,我已经配置了以下JMS侦听器:
In my Spring Boot application I have configured following JMS Listener:
@Component
public class Consumer {
@JmsListener(destination = "image.index.queue")
public void receiveQueue(IndexRequest indexRequest) {
...
}
}
如何从配置(application.properties)中提供目标名称"image.index.queue"而不是硬编码值?
How to supply destination name "image.index.queue" from configuration(application.properties) instead of hard-coded value ?
推荐答案
import org.springframework.beans.factory.annotation.Value;
@JmsListener(destination = @Value("${jmx.image.index.queue}")
public void receiveQueue(IndexRequest indexRequest) {
...
}
在您的属性文件中
jmx.image.index.queue=image.index.queue
这篇关于配置中的Spring注释值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文