我的 Spring 启动项目无法访问 EC2 实例上使用的 RDS 数据库实例



我可以在MySQL工作台上使用SSH私钥访问使用EC2实例的RDS DB实例。但在Intellij上,我无法访问数据库来运行spring-boot应用程序。如何使用Intellij上的RDS DB在本地运行此项目?application-local.properties如下所示。

...
cloud:
aws:
credentials:
accessKey: xxx
secretKey: xxx
s3:
bucket: my-develop
region:
static: ap-northeast-2

spring:
servlet:
multipart:
max-file-size: 50MB
max-request-size: 50MB
security:
enabled: false
oauth2:
client:
registration:
google:
client-id: xxxxx.apps.googleusercontent.com
client-secret: xxxxx
facebook:
client-id: xxxxxx
client-secret: xxxx
mvc:
view:
prefix: /WEB-INF/view/
suffix: .jsp
devtool:
livereload:
enabled: true
jackson:
serialization:
fail-on-empty-beans: false
default-property-inclusion: always
datasource:
url: jdbc:mysql://my-database.xxxx.ap-northeast-2.rds.amazonaws.com:3306/my_database?characterEncoding=utf-8&serverTimezone=UTC
username: user
password: password
driverClassName: com.mysql.cj.jdbc.Driver
platform: mysql
initialization-mode: always
hikari:
connection-timeout: 5000
validation-timeout: 1000
minimum-idle: 20
maximum-pool-size: 20
max-lifetime: 30000
leak-detection-threshold: 10000
idle-timeout: 10000

"我可以通过MySQL工作台上的SSH私钥访问RDS DB实例,它使用EC2实例"听起来像是在使用EC2实例作为堡垒主机;跳转框";以访问专用RDS数据库。您需要使用SSH端口转发来为本地Spring Boot应用程序完成同样的操作。

最新更新