spring - 如何为在 EC2 实例上运行的 Spring Boot 项目配置 AWS RDS?
问题描述
我有一个 AWS EC2 Linux 实例运行我的 Spring Boot 项目中的一个 jar。我创建了一个 AWS RDS Postgres 实例,并尝试从我的 EC2 实例中运行的服务中调用它。我主要遇到配置问题。下面,我尝试在我的 spring application.properties 文件中进行以下配置:
cloud.aws.rds.capstoneinstance
cloud.aws.rds.capstoneinstance.password = mypassword
cloud.aws.rds.capstoneinstance.username = myusername
cloud.aws.rds.capstoneinstance.readReplicaSupport = true
cloud.aws.rds.capstoneinstance.databaseName = mydbname
这是我的 Gradle 导入:
implementation("org.springframework.cloud:spring-cloud-aws-jdbc:2.1.2.RELEASE")
我的程序甚至不会运行,但我相信那只是因为 spring 正在寻找“spring.datasource.url”等。
这是输出:
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class
Action:
Consider the following:
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
解决方案
如果您使用的是 AWS Aurora RDS 集群(Aurora 引擎),而不是直接使用 AWS RDS Postgres(Postgres 引擎),那么 AWS 云驱动程序似乎不支持该功能。
如果此功能对您很重要,请提供更多详细信息。这是他们的路线图很长一段时间。 https://github.com/awspring/spring-cloud-aws/issues/50
推荐阅读
- python - 在heroku上出现H10错误-使用mongoengine python
- linux - 如何在 linux 中将更新部署到 .NETCore 应用程序
- appimage - 我的 appimage 包包含两个 python 库
- python - 如何在 Keras 中正确加载和使用预训练模型?
- javascript - 在“转到上一页”复选框保持选中状态后,jquery 不会检测到
- javascript - 从 HTML 日期输入中隐藏/禁用年份
- python - 无法在 django rest 框架中以多部分形式上传照片
- linux - Dropwizard 不控制 archivedFileCount
- javascript - 在两个组件之间共享状态 [钩子]
- android - 未接收来自 HFP 的呼叫设置传入指示器