0

我正在尝试在 aws 中的 AmazonMQ 服务下部署RabbitMQ,并使用 terraform 将其连接到 Spring 应用程序。我可以使用带有 terraform 的 AmazonMQ 创建 Rabbit 代理,但在将其连接到 spring 应用程序时遇到问题。这是我的带有 terraform 的 Rabbit 配置。

resource "aws_mq_broker" "rabbit" {
  broker_name   = lower("${var.resource_prefix}-rabbit")
  engine_type   = "RabbitMQ"
  engine_version = "3.8.11"
  host_instance_type = "mq.m5.large"
  publicly_accessible = true
  user {
    username = "user1"
    password = "pwd1"
  }
}

上面的配置创建了一个代理,我可以访问 Rabbit Web 控制台。现在我尝试使用以下配置连接到 spring 应用程序:application.yml

spring:
 rabbitmq:
   addresses: "amqps://b-e80099d2-111-4185-be9d-111111.mq.us east-2.amazonaws.com:5671"
   username: user1
   password: pwd1
   virtual_host: /
   requested-heartbeat: 30s

但是当我运行它时,我得到了错误

通过构造函数参数 5 表示的不满足的依赖关系;嵌套异常是 org.springframework.beans.factory.UnsatisfiedDependencyException:创建名称为“rabbitConfiguration”的 bean 时出错:通过字段“rabbitProperties”表示的依赖关系不满足;嵌套异常是 org.springframework.boot.context.properties.ConfigurationPropertiesBindException:创建名为“spring.rabbitmq-org.springframework.boot.autoconfigure.amqp.RabbitProperties”的 bean 时出错:无法将属性绑定到“RabbitProperties”:prefix=spring .rabbitmq,ignoreInvalidFields=false,ignoreUnknownFields=true;嵌套异常是 org.springframework.boot.context.properties.bind.BindException:无法将“spring.rabbitmq”下的属性绑定到 org.springframework.boot.autoconfigure.amqp。

****************************** 应用程序无法启动


描述:

无法将“spring.rabbitmq”下的属性绑定到 org.springframework.boot.autoconfigure.amqp.RabbitProperties:

Property: spring.rabbitmq.addresses
Value: amqps://b-e80099d2-111-4185-be9d-111111.mq.us east-2.amazonaws.com:5671
Origin: URL [file:./config/application-prod.yml]:23:20
Reason: For input string: ""

不知道为什么错误说输入字符串的原因是“”,但我确实将地址的值为“amqps://b-e80099d2-111-4185-be9d-111111.mq.us east-2.amazonaws。 com:5671"。

有人可以帮忙提出任何建议吗?谢谢!

4

0 回答 0