spring cloud连接rabbitmq失败

遇到一个很操蛋的问题.

spring cloud简单集成 stream

<dependencies>
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter-stream-rabbit</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web-services</artifactId>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-actuator</artifactId>
		</dependency>

		<dependency>
			<groupId>org.springframework.retry</groupId>
			<artifactId>spring-retry</artifactId>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
	</dependencies>

启动, 

配置文件

spring:
  application:
    name: demox-service
    index: ${spring.application.name}
  rabbitmq:
    host: 192.168.0.100
    port: 5672
    username: username
    password: 111111
    virtual-host: /test-config

然后发现日志没有错误,但是mq页面就是没有连接

2018-01-29 18:27:44.615  INFO 64502 --- [           main] com.ex.DemoApplication                   : No active profile set, falling back to default profiles: default
2018-01-29 18:27:44.619  INFO 64502 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@703e8050: startup date [Mon Jan 29 18:27:44 CST 2018]; parent: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@26abb146
2018-01-29 18:27:44.715  INFO 64502 --- [           main] o.s.c.support.GenericApplicationContext  : Refreshing org.springframework.context.support.GenericApplicationContext@120df990: startup date [Mon Jan 29 18:27:44 CST 2018]; root of context hierarchy
2018-01-29 18:27:44.755  INFO 64502 --- [           main] com.ex.DemoApplication                   : Started DemoApplication in 0.19 seconds (JVM running for 6.374)
2018-01-29 18:27:44.831  INFO 64502 --- [           main] c.s.b.r.p.RabbitExchangeQueueProvisioner : declaring queue for inbound: input.anonymous.1b2x3VJNTNmoFKA7NoJyiQ, bound to: input
2018-01-29 18:27:57.637  WARN 64502 --- [           main] o.s.amqp.rabbit.core.RabbitAdmin         : Failed to declare exchange: Exchange [name=input, type=topic, durable=true, autoDelete=false, internal=false, arguments={}], continuing... org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Connection refused (Connection refused)
2018-01-29 18:27:57.638  WARN 64502 --- [           main] o.s.amqp.rabbit.core.RabbitAdmin         : Failed to declare queue: Queue [name=input.anonymous.1b2x3VJNTNmoFKA7NoJyiQ, durable=false, autoDelete=true, exclusive=true, arguments={}], continuing... org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Connection refused (Connection refused)
2018-01-29 18:27:57.642  WARN 64502 --- [           main] o.s.amqp.rabbit.core.RabbitAdmin         : Failed to declare binding: Binding [destination=input.anonymous.1b2x3VJNTNmoFKA7NoJyiQ, exchange=input, routingKey=#], continuing... org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Connection refused (Connection refused)
2018-01-29 18:27:57.677  INFO 64502 --- [           main] o.s.i.a.i.AmqpInboundChannelAdapter      : started inbound.input.anonymous.1b2x3VJNTNmoFKA7NoJyiQ

然后仔细看日志:

Failed to declare exchange,出现一堆的Failed.

进入他的源代码调试一下 AmqpConnectException

原来配置文件没有读取正确.坑死人了.

 

加入config依赖

		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter-config</artifactId>
		</dependency>

然后就能正常读取配置,连接mq就成功了...

转载于:https://my.oschina.net/u/1538135/blog/1615129

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值