【发布时间】:2018-03-15 19:54:44
【问题描述】:
我正在开发一个在 AWS 上运行的 Spring Boot 应用程序。我已经安装了 Spring Cloud AWS 启动器,但是当我尝试在我的笔记本电脑上本地运行集成测试时,我遇到了这个错误。
使用名称“org.springframework.cloud.aws.context.support.io.ResourceLoaderBeanPostProcessor#0”创建 bean 时出错:在设置构造函数参数时无法解析对 bean“amazonS3”的引用;嵌套异常是 org.springframework.beans.factory.BeanCreationException:创建名为“amazonS3”的 bean 时出错:调用 init 方法失败;嵌套异常是 java.lang.IllegalStateException: 没有可用的 EC2 元数据,因为应用程序没有在 EC2 环境中运行。只有当应用程序在 EC2 实例上运行时,才能进行区域检测
有没有办法在没有 AWS 的情况下运行我的应用程序?仅用于本地集成测试。
【问题讨论】:
-
如果您在 AWS 环境之外运行应用程序。为避免该错误,请在 application.properties 文件中指定区域手册,如下所示
cloud.aws.region.static=eu-west-1 -
这解决了我的问题。
标签: spring amazon-web-services spring-boot amazon-ec2 spring-cloud