gpt4 book ai didi

spring - 非常慢的 Spring Boot 应用程序启动

转载 作者:IT老高 更新时间:2023-10-28 13:45:28 33 4
gpt4 key购买 nike

我有一个简单的 Spring Boot 应用程序,它连接到 PostgreSQL 数据库并用作 JSON 服务。不知何故,启动变得非常缓慢,请参阅时间 10:37:10 和 10:38:00:

2015-05-09 10:37:09.649  INFO 20880 --- [lication.main()] o.apache.catalina.core.StandardService   : Starting service Tomcat
2015-05-09 10:37:09.651 INFO 20880 --- [lication.main()] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.0.20
2015-05-09 10:37:09.767 INFO 20880 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2015-05-09 10:37:09.767 INFO 20880 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2970 ms
2015-05-09 10:37:09.979 INFO 20880 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2015-05-09 10:37:09.985 INFO 20880 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2015-05-09 10:37:10.105 INFO 20880 --- [lication.main()] o.s.j.d.DriverManagerDataSource : Loaded JDBC driver: org.postgresql.Driver
2015-05-09 10:37:10.214 INFO 20880 --- [lication.main()] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2015-05-09 10:37:10.233 INFO 20880 --- [lication.main()] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2015-05-09 10:37:10.585 INFO 20880 --- [lication.main()] org.hibernate.Version : HHH000412: Hibernate Core {4.3.8.Final}
2015-05-09 10:37:10.587 INFO 20880 --- [lication.main()] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2015-05-09 10:37:10.589 INFO 20880 --- [lication.main()] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist
2015-05-09 10:37:10.968 INFO 20880 --- [lication.main()] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {4.0.5.Final}
2015-05-09 10:38:00.023 INFO 20880 --- [lication.main()] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect
2015-05-09 10:38:00.041 INFO 20880 --- [lication.main()] o.h.e.jdbc.internal.LobCreatorBuilder : HHH000424: Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException
2015-05-09 10:38:00.274 INFO 20880 --- [lication.main()] o.h.h.i.ast.ASTQueryTranslatorFactory : HHH000397: Using ASTQueryTranslatorFactory

有什么想法吗?我可以做些什么来诊断问题吗?

最佳答案

对于 Spring Boot,您可以在 application.properties 文件中进行设置:

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

我还发现我需要设置另一个属性,否则我会收到错误“org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set”。为了纠正我设置了这个属性:

spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect

这将我们的启动时间从大约 100 秒减少到 12 秒。

关于spring - 非常慢的 Spring Boot 应用程序启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30133544/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com