我正在集成springboot+jpa+oracle。我成功地用创建和删除了数据库 spring.jpa.hibernate.ddl-auto=create-drop
,但当我将属性更改为 spring.jpa.hibernate.ddl-auto=update
,spring boot挂起,应用程序未启动。
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: 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` :
==== 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
1条答案
按热度按时间pqwbnv8z1#
这可能是一个评论,但它的工具长的评论,所以我张贴这个作为一个答案。以下是一些可以为您指明正确方向的想法:
想法1
当你使用
update
作为这个财产的价值-很多事情实际上发生了,远远超过drop-create
. 事实上,java试图读取大量关于模式的“元数据”,并根据jpa/hibernate中定义的Map来调整表。要了解更多细节,请确保您正在阅读这篇文章。顺便说一句,在阅读了详细解释了当您将此属性设置为
update
-也许你会得出结论,你其实并不需要它;)长话短说,很可能(这只是猜测)您的应用程序确实在后台“做”一些事情,一些耗时的操作可能需要相当长的时间。因此,尝试进行线程转储,并检查是否看到任何“正在运行”的线程。
想法2
另一个可能的原因是您没有读取元数据/任何其他操作的权限(这实际上取决于您设置oracle数据库的方式)。缓解措施很难在这里描述——可能您应该看看dba或其他方面会发生什么,可能有很多原因会让您陷入java,或者可能有一个锁——谁知道呢。
想法3
您可能还需要记录spring启动应用程序在启动时运行的sql命令。可以在驱动程序级别、hibernate/spring级别等启用对oracle驱动程序的跟踪。