Reputation: 1518
I've been running Spring-Boot with JPA and a Postgres Database. Depending on my network environment the starting phase is blocking for more than 15 sec on :
INFO o.h.tool.hbm2ddl.SchemaValidator - HHH000229: Running schema validator
The strange thing is that my Database is local. Any idea ?
spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults=false
spring.jpa.hibernate.ddl-auto= validate
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
spring.datasource.driverClassName=org.postgresql.Driver
spring.datasource.url=jdbc:postgresql://localhost:5432/cine
Upvotes: 7
Views: 8251
Reputation: 3432
Check your application.yml.
jpa:
database: MYSQL
show-sql: true
hibernate:
ddl-auto : none
if ddl-auto's value is update, please change it to none instead, then it should be much faster.
Upvotes: -1
Reputation: 6082
I had the same issue with JPA (Eclipselink) and Mysql database when i start the application it took like 1 minute to create 4 empty simple tables.
i was seeing logs like:
create table if not exist ... then it says error table already exist.
each log record of the above took about 15 seconds.
however, after searching around, someone suggested using latest Mysql connector Driver (Jar file) i did so and it works fine now.
so try to use different or newer connector jar file, in your case for postgresql it would be here
Upvotes: 0
Reputation: 6182
The schema validator is just slow. We ended up adding this line to our spring configuration file for our "dev" environment profile (application-dev.properties)
spring.jpa.hibernate.ddl-auto=none
This is a bit risky, since the consistency between the database and JPA entities are not verified. But, we have both Test- and QA environments that would pick up any problems.
This fix did cut my startup process by about 20 seconds.
Upvotes: 3
Reputation: 5249
In any problem like this get hold of a profiler (Yourkit is excellent) and profile your app at startup to see what's taking the time. Yourkit not only will show you hotspots (methods taking disproportionately longer times) but will also show you any database queries and how long they took.
Make sure you start profiling in full trace mode (this can be configured in your IDE e.g. in IntelliJ on the startup tab of your run configuration).
Upvotes: 0