gpt4 book ai didi

来自配置的 Spring 注释值

转载 作者:行者123 更新时间:2023-12-02 02:24:12 25 4
gpt4 key购买 nike

在我的 Spring Boot 应用程序中,我配置了以下 JMS 监听器:

@Component
public class Consumer {

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

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

最佳答案

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 注释值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38125348/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com