Spring 来自配置的注释值
Spring annotation value from configuration
在我的 Spring 引导应用程序中,我配置了以下 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 引导应用程序中,我配置了以下 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