【问题标题】:Eclipse Spring Boot Project Not Connecting to AWS DatabaseEclipse Spring Boot 项目未连接到 AWS 数据库
【发布时间】:2022-01-17 10:50:10
【问题描述】:

我有一个项目,我们连接到 AWS 数据库以运行 Spring Boot 启动项目(使用 java、html 和 css)。我在程序中没有编译错误,但是当我运行程序通过代码工作时,spring boot程序被终止而没有成功运行。我尝试查看代码的几个不同方面,但找不到任何问题。我也安装了tomcat。任何帮助或反馈将不胜感激。我为我的 Spring Boot 程序附加了下面的应用程序属性。如果还有什么有用的,请告诉我。

主要错误:java.sql.SQLNonTransientConnectionException:不允许检索公钥 应用程序.properties


##spring.datasource.url=jdbc:mysql://cis175group.c3yjnhalr3i9.us-east-1.rds.amazonaws.com/petreg?useSSL=false
spring.datasource.url=jdbc:mysql://localhost:3306/petreg?useSSL=false
##spring.datasource.username=admin
##spring.datasource.password=airplanecar
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

spring.datasource.username=root
spring.datasource.password=password
spring.jpa.database-platform = org.hibernate.dialect.MySQL8Dialect
spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto = update

# ==============================================================
# = Show or not log for each sql query
# ==============================================================
spring.jpa.show-sql = true 
spring.jpa.properties.hibernate.format_sql = true ```

【问题讨论】:

    标签: java mysql spring-boot tomcat


    【解决方案1】:

    由于您没有提供运行应用程序时遇到的错误,因此很难确定确切的问题。但我将首先验证 AWS DB (MySQL) 是否可以公开访问。尝试从 MySQL 工作台连接您的数据库实例,以检查您是否能够连接到它。如果不是,很可能是因为您的 AWS 数据库不公开。您必须通过在 AWS 控制台中更改此设置使其在 AWS 外部可访问:

    【讨论】:

    • 错误是:java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed - 我假设您在公共访问中是正确的。我会处理这个问题,看看是否有帮助。谢谢!
    • 更新:很遗憾,我仍然无法让事情正常工作。我在上面的评论中仍然遇到同样的错误,但我还在我的代码中添加了 allowPublicKeyRetrieval=true 并且 AWS 数据库是公开可用的。
    猜你喜欢
    • 1970-01-01
    • 2018-09-23
    • 2020-07-29
    • 2022-10-02
    • 1970-01-01
    • 2018-10-10
    • 1970-01-01
    • 1970-01-01
    • 2020-01-30
    相关资源
    最近更新 更多