Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring boot 如何使用SpringRabbit配置RabbitMQ连接?_Spring Boot_Rabbitmq_Spring Amqp_Spring Rabbit - Fatal编程技术网

Spring boot 如何使用SpringRabbit配置RabbitMQ连接?

Spring boot 如何使用SpringRabbit配置RabbitMQ连接?,spring-boot,rabbitmq,spring-amqp,spring-rabbit,Spring Boot,Rabbitmq,Spring Amqp,Spring Rabbit,下面我将学习如何在RabbitMQ中使用SpringRabbit。但是,在本指南中,RabbitMQ配置为默认配置(localhost服务器,凭据为guest/guest)。如果我想使用ip地址和凭据连接到远程RabbitMQ,我应该怎么做?我不知道在我的应用程序中在哪里设置这些信息。该指南的应用程序是Spring Boot应用程序 将文件application.properties添加到src/main/resources 然后,您可以根据-向下滚动到rabbitmq属性来配置rabbitmq

下面我将学习如何在RabbitMQ中使用
SpringRabbit
。但是,在本指南中,RabbitMQ配置为默认配置(localhost服务器,凭据为guest/guest)。如果我想使用ip地址和凭据连接到远程RabbitMQ,我应该怎么做?我不知道在我的应用程序中在哪里设置这些信息。

该指南的应用程序是Spring Boot应用程序

将文件
application.properties
添加到
src/main/resources

然后,您可以根据-向下滚动到rabbitmq属性来配置rabbitmq属性

...
spring.rabbitmq.host=localhost # RabbitMQ host.
...
spring.rabbitmq.password= # Login to authenticate against the broker.
spring.rabbitmq.port=5672 # RabbitMQ port.
...
spring.rabbitmq.username= # Login user to authenticate to the broker.
...
要连接到群集,请使用

spring.rabbitmq.addresses= # Comma-separated list of addresses to which the client should connect.
e、 g.
server1:5672,server2:5672


如果您不想使用引导自动配置,请自己声明一个
CachingConnectionFactory
@Bean
并根据需要对其进行配置。

这很奇怪,我按照您的建议将这些属性添加到
应用程序中。但是,这些属性似乎尚未加载到正在运行的应用程序中。我错过了什么?我刚刚下载了指南,为
完整版
添加了
application.properties
src/main/resources
,并将其指向一个远程rabbitmq实例,它工作得很好-我看到了在rabbit实例上创建的队列和输出消息。你是怎么运行指南的?我的错,对不起,你的解决方案很有效。这里不起作用,因为我在我的配置类中添加了
@Bean MessageListenerAdapter listenerAdapter(Receiver Receiver){return new MessageListenerAdapter(Receiver,“receiveMessage”);}
;见和。与其在对旧问题的评论中提出新问题,不如提出一个全新的问题。