简体   繁体   English

Spring 引导/休眠:未创建表

[英]Spring boot/Hibernate: Tables not getting created

My application was creating tables earlier.我的应用程序之前正在创建表。 I was running into "detached entity passed to persist" exception during which I found out that the date/time was null. To fix the issue so that I can debug the problem, I dropped all the tables in the dev environment and re-ran the application.我遇到了“detached entity passed to persist”异常,在此期间我发现日期/时间是 null。为了解决这个问题以便我可以调试问题,我删除了开发环境中的所有表并重新运行应用程序。 Now my tables are no longer getting created.现在我的表不再被创建。

Any suggestions on what is that I messed up?关于我搞砸了什么的任何建议?

Relevant application.properties are as below:相关的application.properties如下:

spring.datasource.url=jdbc:mysql://localhost:3306/XXX
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.properties.hibernate.id.new_generator_mappings = false
spring.jpa.properties.hibernate.format_sql = true
spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.show-sql = true
spring.jpa.generate-ddl=true

I am seeing below errors during startup:我在启动期间看到以下错误:

2022-03-07 14:13:36.666 DEBUG 37790 --- [main] .h.t.s.s.SchemaManagementToolCoordinator : No actions specified; doing nothing
2022-03-07 14:13:36.667 DEBUG 37790 --- [main] o.h.e.t.j.p.i.JtaPlatformInitiator       : No JtaPlatform was specified, checking resolver
2022-03-07 14:13:36.667 DEBUG 37790 --- [main] h.e.t.j.p.i.JtaPlatformResolverInitiator : No JtaPlatformResolver was specified, using default [org.hibernate.engine.transaction.jta.platform.internal.StandardJtaPlatformResolver]
2022-03-07 14:13:36.671 DEBUG 37790 --- [main] .h.e.t.j.p.i.StandardJtaPlatformResolver : Could not resolve JtaPlatform, using default [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2022-03-07 14:13:36.671  INFO 37790 --- [main] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2022-03-07 14:13:36.672 DEBUG 37790 --- [main] o.h.q.s.NamedQueryRepository             : Checking 0 named HQL queries
2022-03-07 14:13:36.672 DEBUG 37790 --- [main] o.h.q.s.NamedQueryRepository             : Checking 0 named SQL queries

I do see that the LoadPlan is properly getting created.我确实看到 LoadPlan 已正确创建。 I tried with spring.jpa.hibernate.ddl-auto=create as well.我也尝试使用 spring.jpa.hibernate.ddl-auto=create。

i think as you use spring.jpa.hibernate.ddl-auto=create-drop if you application runs normally you will find your tables but if crashed or throws error the spring make rollback to created tables if any我认为当你使用spring.jpa.hibernate.ddl-auto=create-drop如果你的应用程序正常运行你会发现你的表但如果崩溃或抛出错误 spring 回滚到创建的表(如果有)

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

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