简体   繁体   English

Spring JPA - Hibernate 不向表中添加列

[英]Spring JPA - Hibernate not adding columns to the table

I saw so many answers here, but couldn't find the one that could solve my problem.我在这里看到了很多答案,但找不到可以解决我问题的答案。

problem: When I add the field in my entity class, hibernate does not update it in mysql automatically so I have to do it manually which is annoying.问题:当我在实体类中添加字段时,hibernate 不会在 mysql 中自动更新它,所以我必须手动进行,这很烦人。

Here is my application.properties content:这是我的 application.properties 内容:

spring.datasource.url=jdbc:mysql://127.0.0.1:3306/mysql?createDatabaseIfNotExist=true&autoReconnect=true
spring.datasource.username=root
spring.datasource.password=
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect
spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto=update

Thanks in advance!提前致谢!

我需要查看您的实体类,但如果您想更新或向数据库添加任何内容,最好使用迁移工具(例如 flyway)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM