Spring Boot App 在 H2 上运行,但在 AWS RDS 上失败

Spring Boot App works on H2, but fails on AWS RDS

我用 H2 数据库创建了一个简单的项目管理应用程序,它运行良好。但是,当我尝试在 AWS 上将数据源更改为 mysql 时,出现错误:

java.sql.SQLException: Access denied for user 'admin'@'ip.com' (using password: YES)
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'iEmpRepo' defined in com.pma.scratch.demo.repos.iEmpRepo defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Cannot resolve reference to bean 'jpaMappingContext' while setting bean property 'mappingContext'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaMappingContext': Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]

现在我确定我的连接凭据是正确的,因为我使用 DataGrip 连接得很好,我什至在 intellij 中创建了一个新的 spring 启动应用程序,我能够连接到同一个数据库并且使用 jpa 创建表。

这是应用程序属性文件。

spring.datasource.url=jdbc:mysql://mysql.....:3306/database_name
spring.datasource.username=admin
spring.datasource.password=*****

不知道为什么我会收到拒绝访问错误,BeanCreation 错误让我感到困惑,因为我的应用程序使用 H2 可以很好地创建 bean。

我认为驱动程序丢失了。添加:

spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver

spring.datasource.driverClassName=com.mysql.jdbc.Driver

别忘了罐子

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>8.0.22</version>
</dependency> 

如果错误仍然存​​在,请使用此 属性

获取更多日志
debug=true