Can';t从本地Spring boot连接AWS RDS
我可以使用MySQL Workbench连接AWS RDS,但当尝试从本地spring启动连接时,它说表不存在。与我的本地MySQL相同的代码。 所以我不确定问题出在哪里 应用程序属性Can';t从本地Spring boot连接AWS RDS,spring,spring-boot,spring-data-jpa,Spring,Spring Boot,Spring Data Jpa,我可以使用MySQL Workbench连接AWS RDS,但当尝试从本地spring启动连接时,它说表不存在。与我的本地MySQL相同的代码。 所以我不确定问题出在哪里 应用程序属性 spring.datasource.url = jdbc:mysql://host:3306/db spring.datasource.username = user spring.datasource.password = password-1 spring.jpa.properties.hibernate.d
spring.datasource.url = jdbc:mysql://host:3306/db
spring.datasource.username = user
spring.datasource.password = password-1
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect
错误消息:
HHH000397: Using ASTQueryTranslatorFactory
SQL Error: 1146, SQLState: 42S02
Table 'db.student' doesn't exist
Resolved [org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet]
HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=1m42s281ms410µs591ns).
对这个错误有什么看法。谢谢你的帮助 找到答案的一种方法是使用
spring.jpa.hibernate.ddl auto=create
这将基于当前实体类在数据库中创建一个名为student
的表。我怀疑你的学生
表中有大写字母?因为hibernate会将您的表名(比如@table(name=“MyTable”)
)简单地映射到myu表。假设您有@Table(name=“Student”)
,数据库中的表名为Student
。假设Hibernate 5,您需要通过设置spring.jpa.Hibernate.naming.physical strategy=org.Hibernate.boot.model.naming.physicalnamingstrategstandardimpl来覆盖Hibernate的隐式命名策略。或者您也可以提供自己的,以供参考:请提供应用程序.properties
文件。请记住更改/删除敏感数据。配置看起来正常。你也能提供日志吗?我们可能希望看到错误。更新的错误消息db模式中是否有学生表如果我正确理解错误日志,则代码/模式有问题。它连接到数据库。是的,我注意到错误消息所有小写字母,但实际表名所有大写字母。希望这就是问题的原因。如何使用hibernate使access数据库不区分大小写?或使用此类案例的任何替代方案。请建议。spring.jpa.hibernate.naming.physical strategy=org.hibernate.boot.model.naming.physicalngstrategyandardiml
将此添加到属性文件中将覆盖spring自动配置默认使用的ImplicitNamingStrategy
。这样做允许@Table(name=“Student”)
映射到实际数据库中的Student表。