升级到Spring Boot 2.2.2后,应用程序启动时间变慢

时间:2019-12-23 18:13:04

标签: spring-boot

我已将应用程序升级到Spring Boot 2.2.2,现在启动时间在30秒范围内。

:: Built with Spring Boot :: 2.2.2.RELEASE
2019-12-23 10:38:06.822  INFO 4669 --- [  restartedMain] c.d.l.i.r.IdeaSubmissionRestApplication  : Starting IdeaSubmissionRestApplication on wsm-93.local with PID 4669 (/Users/mhast/Developer/sts_workspaces_4_4_1/dss/ldrd_s/IdeaSubmissionRest/target/classes started by mhast in /Users/mhast/Developer/sts_workspaces_4_4_1/dss/ldrd_s/IdeaSubmissionRest)
2019-12-23 10:38:06.826  INFO 4669 --- [  restartedMain] c.d.l.i.r.IdeaSubmissionRestApplication  : The following profiles are active: dev
...
2019-12-23 10:38:08.440  INFO 4669 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8320 (http)
2019-12-23 10:38:08.447  INFO 4669 --- [  restartedMain] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2019-12-23 10:38:08.448  INFO 4669 --- [  restartedMain] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.29]
2019-12-23 10:38:08.512  INFO 4669 --- [  restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2019-12-23 10:38:08.512  INFO 4669 --- [  restartedMain] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1530 ms
2019-12-23 10:38:08.678  INFO 4669 --- [  restartedMain] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2019-12-23 10:38:09.189  INFO 4669 --- [  restartedMain] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2019-12-23 10:38:09.234  INFO 4669 --- [  restartedMain] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]
2019-12-23 10:38:09.285  INFO 4669 --- [  restartedMain] org.hibernate.Version                    : HHH000412: Hibernate Core {5.4.9.Final}
2019-12-23 10:38:09.370  INFO 4669 --- [  restartedMain] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2019-12-23 10:38:09.456  INFO 4669 --- [  restartedMain] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.Oracle10gDialect
2019-12-23 10:38:37.903  INFO 4669 --- [  restartedMain] org.hibernate.tuple.PojoInstantiator     : HHH000182: No default (no-argument) constructor for class: com.desertsky.ldrd.model.entities.FrsFactTableViewId (class must be instantiated by Interceptor)
2019-12-23 10:38:39.038  INFO 4669 --- [  restartedMain] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2019-12-23 10:38:39.043  INFO 4669 --- [  restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2019-12-23 10:38:40.109  WARN 4669 --- [  restartedMain] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning

Oracle10gDialect的加载从10:38:09.456开始,下一个日志是28秒后。

2019-12-23 10:38:09.456  INFO 4669 --- [  restartedMain] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.Oracle10gDialect
2019-12-23 10:38:37.903  INFO 4669 --- [  restartedMain] org.hibernate.tuple.PojoInstantiator     : HHH000182: No default (no-argument) constructor for class: com.desertsky.ldrd.model.entities.FrsFactTableViewId (class must be instantiated by Interceptor)

有人知道为什么升级到Spring Boot 2.2.2之后方言加载这么慢吗?

1 个答案:

答案 0 :(得分:0)

我在这篇文章中找到了答案。

Very slow Spring Boot application startup

我将此属性添加到了application.properties文件中,回到了快速的应用程序启动状态。

spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults=false

JBoss Hibernate文档说:

This setting is used to control whether we should consult the JDBC metadata to determine certain Settings default values when the database may not be available (mainly in tools usage).