来自配置的Spring注释值

时间:2016-06-30 13:58:10

标签: spring spring-boot jms spring-annotations

在我的Spring Boot应用程序中,我已经配置了以下JMS Listener:

@Component
public class Consumer {

    @JmsListener(destination = "image.index.queue")
    public void receiveQueue(IndexRequest indexRequest) {
        ...
    }

}

如何提供目的地名称" image.index.queue"从配置(application.properties)而不是硬编码值?

1 个答案:

答案 0 :(得分:4)

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
相关问题