我可以使用MySQL工作台连接AWS,但是当尝试从本地spring启动连接时,它说表不存在。使用本地MySQL的相同代码。所以不知道会有什么问题。
application.properties
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).对这个错误有什么想法吗。感谢你的帮助!
发布于 2019-01-18 14:43:42
找到答案的一种方法是使用spring.jpa.hibernate.ddl-auto=create,这将根据当前实体类在数据库中创建一个名为student的表。我怀疑你们的student表里有大写字母吗?因为hibernate隐式地将您的表名(比如@Table(name = "MyTable") )映射到my_table。假设您有@Table(name="Student"),数据库中的表名为Student。假设Hibernate 5,您需要通过设置ImplicitNamingStrategy来覆盖Hibernate的spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl。或者你也可以提供你自己的参考:https://www.baeldung.com/hibernate-naming-strategy
https://stackoverflow.com/questions/54255231
复制相似问题