简体   繁体   English

spring.jpa.hibernate.ddl-auto=更新在 Z2A2D5925E6ED9AB134D636 中不起作用

[英]spring.jpa.hibernate.ddl-auto=update not working in spring boot

I am integrating spring boot + jpa + oracle.我正在集成 spring 引导 + jpa + oracle。 I was successful in creating and drop the database with spring.jpa.hibernate.ddl-auto=create-drop , but when I change the property to spring.jpa.hibernate.ddl-auto=update , spring boot hangs up and the application is not starting up. I was successful in creating and drop the database with spring.jpa.hibernate.ddl-auto=create-drop , but when I change the property to spring.jpa.hibernate.ddl-auto=update , spring boot hangs up and the application没有启动。

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.3.1.RELEASE)

2021-01-03 00:54:49.024  INFO 40612 --- [           main] com.walmart.DemoApplication     : Starting DemoApplication on m-c02dj138ml85 with PID 40612 (/Users/b0j02tw/Documents/demo/target/classes started by b0j02tw in /Users/b0j02tw/Documents/demo)
2021-01-03 00:54:49.026  INFO 40612 --- [           main] com.walmart.DemoApplication     : No active profile set, falling back to default profiles: default
2021-01-03 00:54:49.325  INFO 40612 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFERRED mode.
2021-01-03 00:54:49.367  INFO 40612 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 35ms. Found 1 JPA repository interfaces.
2021-01-03 00:54:49.656  INFO 40612 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2021-01-03 00:54:49.684  INFO 40612 --- [         task-1] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]
2021-01-03 00:54:49.719  INFO 40612 --- [         task-1] org.hibernate.Version                    : HHH000412: Hibernate ORM core version 5.4.17.Final
2021-01-03 00:54:49.733  INFO 40612 --- [           main] DeferredRepositoryInitializationListener : Triggering deferred initialization of Spring Data repositories…
2021-01-03 00:54:49.823  INFO 40612 --- [         task-1] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2021-01-03 00:54:49.891  INFO 40612 --- [         task-1] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2021-01-03 00:54:53.118  INFO 40612 --- [         task-1] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2021-01-03 00:54:53.148  INFO 40612 --- [         task-1] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.Oracle10gDialect

application.properties : application.properties

#==== Looging properties ======#
#debug=true
#==== Looging root levels - TRACE, DEBUG, INFO, WARN, ERROR, OFF ======#
logging.level.root=INFO


spring.datasource.driver-class-name=oracle.jdbc.OracleDriver
##===== START - OracleDB connection settings ======#
spring.datasource.url=jdbc:oracle:thin:@//****
spring.datasource.username=***
spring.datasource.password=******
spring.jpa.hibernate.ddl-auto=update
##===== END - OracleDB connection settings ======#
#

##====== START - JPA settings ======

##===== END - OracleDB connection settins ======#
#

#SQL FOR DEBUGGING
spring.jpa.show-sql=true

This could be a comment but its kind of tool long for the comment so I post this as an answer.这可能是一条评论,但它是一种很适合评论的工具,所以我将其发布为答案。 Here are some ideas that can point you on the right direction:以下是一些可以为您指明正确方向的想法:

Idea 1理念一

When you use update as this property value - a lot of things actually happen, way more than drop-create .当您使用update作为此属性值时-实际上会发生很多事情,而不仅仅是drop-create In fact Java tries to read a lot of "meta-data" about your schema and adjust the tables in accordance with the mapping defined in JPA/Hibernate.事实上,Java 尝试读取有关您的架构的大量“元数据”,并根据 JPA/Hibernate 中定义的映射调整表。

For more details, make sure, you're reading this SO thread .有关更多详细信息,请确保您正在阅读此 SO 线程 BTW after reading the answer that explains in details what happens when you set this property to be update - maybe you'll come to conclusion that you don't really need it;)顺便说一句,在阅读详细解释了当您将此属性设置为update时会发生什么的答案后 - 也许您会得出结论,您并不真的需要它;)

Long story short, its possible (and this is just a guess) that your application is really "doing" something in a background, some time consuming operations that can take quite a while.长话短说,您的应用程序可能(这只是一个猜测)确实在后台“做”某事,一些耗时的操作可能需要相当长的时间。 So try to take a thread dump and check whether you see any "running" threads.因此,尝试进行线程转储并检查您是否看到任何“正在运行”的线程。

Idea 2想法 2

Another possible reason is that you don't have permissions to read metadata/any other operation (it really depends on how exactly you've set up your Oracle Database).另一个可能的原因是您没有读取元数据/任何其他操作的权限(这实际上取决于您设置 Oracle 数据库的准确程度)。 The mitigation is hard to describe here - probably you should see what happens with the DBA or something, there might be really a lot of reasons for getting stuck in java, or maybe there is a lock - who knows.缓解在这里很难描述——也许你应该看看 DBA 发生了什么,可能有很多原因会卡在 java 中,或者可能有锁——谁知道呢。

Idea 3想法 3

You might also want to log the SQL commands that your spring boot application runs upon the start.您可能还想记录 spring 启动应用程序在启动时运行的 SQL 命令。 Its possible to enable tracing for oracle driver (at the level of the driver), at the level of hibernate / spring, etc. So again, think about this direction.可以在 hibernate / spring 等级别启用对 oracle 驱动程序(在驱动程序级别)的跟踪。所以再想想这个方向。

暂无
暂无

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

相关问题 "Hibernate-Spring boot : spring.jpa.hibernate.ddl-auto=update 更新实体后重新创建表和列" - Hibernate-Spring boot : spring.jpa.hibernate.ddl-auto=update recreates tables and columns after update the entity Spring spring.jpa.hibernate.ddl-auto等于validate时Boot 2.3启动失败 - Spring Boot 2.3 fails to start when spring.jpa.hibernate.ddl-auto equals to validate “spring.jpa.hibernate.ddl-auto”属性用于迁移? - "spring.jpa.hibernate.ddl-auto" property is used for migration? spring.jpa.hibernate.ddl-auto = update mariadb无法自动创建数据库索引或外键或列 - spring.jpa.hibernate.ddl-auto=update mariadb can not auto create Database indexes or Foreign key or column 在springboot启动期间验证“ spring.jpa.hibernate.ddl-auto” - Validate “spring.jpa.hibernate.ddl-auto” during springboot startup spring.jpa.hibernate.ddl-auto = create在带有SpringBoot 2.0的Hibernate 5中不起作用 - spring.jpa.hibernate.ddl-auto=create is not working in Hibernate 5 with SpringBoot 2.0 似乎 JPA spring.jpa.ZCB1F008EEBF5012C4EF419A2Cldd-autoZ77 不起作用。 - Seems JPA spring.jpa.hibernate.ddl-auto=update doesn't work application.properties 中 spring.jpa.hibernate.ddl-auto=update 的问题 - Problem with spring.jpa.hibernate.ddl-auto=update in application.properties Spring JPA spring.jpa.hibernate.ddl-auto:create ORA-02000:缺少ALWAYS关键字 - Spring jpa spring.jpa.hibernate.ddl-auto:create ORA-02000: missing ALWAYS keyword 当为 Postgres DB 的属性 spring.jpa.hibernate.ddl-auto 提供更新值时,Hibernate 不会生成序列 - Hibernate does not generate sequences when update value is provided to the property spring.jpa.hibernate.ddl-auto for Postgres DBs
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM