问题
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) {
...
}
}
How to supply destination name "image.index.queue" from configuration(application.properties) instead of hard-coded value ?
回答1:
import org.springframework.beans.factory.annotation.Value;
@JmsListener(destination = @Value("${jmx.image.index.queue}")
public void receiveQueue(IndexRequest indexRequest) {
...
}
And in your properties file
jmx.image.index.queue=image.index.queue
来源:https://stackoverflow.com/questions/38125348/spring-annotation-value-from-configuration