1

我在Eclipse中基于mariadb、hibernate、spring-boot等常用库写了一个Spring小项目。当我正常运行我的应用程序时,它会在大约十秒钟内完成启动:

2019-11-07 19:53:47.539  INFO 2887 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate Core {5.3.11.Final}
2019-11-07 19:53:47.541  INFO 2887 --- [           main] org.hibernate.cfg.Environment            : HHH000206: hibernate.properties not found
2019-11-07 19:53:47.687  INFO 2887 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.0.4.Final}
2019-11-07 19:53:47.799  INFO 2887 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.MariaDB103Dialect
2019-11-07 19:53:55.078  INFO 2887 --- [           main] o.h.t.schema.internal.SchemaCreatorImpl  : HHH000476: Executing import script 'org.hibernate.tool.schema.internal.exec.ScriptSourceInputNonExistentImpl@3400d6fa'
2019-11-07 19:53:55.083  INFO 2887 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2019-11-07 19:53:55.336  INFO 2887 --- [           main] o.h.h.i.QueryTranslatorFactoryInitiator  : HHH000397: Using ASTQueryTranslatorFactory
2019-11-07 19:53:55.681  INFO 2887 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2019-11-07 19:53:55.706  WARN 2887 --- [           main] aWebConfiguration$JpaWebMvcConfiguration : 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
2019-11-07 19:53:55.893  INFO 2887 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2019-11-07 19:53:55.897  INFO 2887 --- [           main] petmenu.Application                      : Started Application in 10.373 seconds (JVM running for 11.18)

当我在调试模式下启动它时,它需要十倍的时间。

2019-11-07 19:36:40.265  INFO 2108 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate Core {5.3.11.Final}
2019-11-07 19:36:40.267  INFO 2108 --- [           main] org.hibernate.cfg.Environment            : HHH000206: hibernate.properties not found
2019-11-07 19:36:40.615  INFO 2108 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.0.4.Final}
2019-11-07 19:36:40.792  INFO 2108 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.MariaDB103Dialect
2019-11-07 19:36:48.625  INFO 2108 --- [           main] o.h.t.schema.internal.SchemaCreatorImpl  : HHH000476: Executing import script 'org.hibernate.tool.schema.internal.exec.ScriptSourceInputNonExistentImpl@57afe44b'
2019-11-07 19:36:48.628  INFO 2108 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2019-11-07 19:36:48.972  INFO 2108 --- [           main] o.h.h.i.QueryTranslatorFactoryInitiator  : HHH000397: Using ASTQueryTranslatorFactory
2019-11-07 19:37:44.033  INFO 2108 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2019-11-07 19:37:51.931  WARN 2108 --- [           main] aWebConfiguration$JpaWebMvcConfiguration : 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
2019-11-07 19:38:19.658  INFO 2108 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2019-11-07 19:38:19.722  INFO 2108 --- [           main] petmenu.Application                      : Started Application in 103.693 seconds (JVM running for 105.206)

我注意到这项任务特别需要将近一分钟,而在正常启动时它是瞬时的。

2019-11-07 19:36:48.972  INFO 2108 --- [           main] o.h.h.i.QueryTranslatorFactoryInitiator  : HHH000397: Using ASTQueryTranslatorFactory
4

5 回答 5

4

自动解决方案:启动 Eclipse 的干净执行。

如果您使用的是独立 IDE

eclipse --clean

如果您使用的是 Spring Tool Suite

STS --clean

你只需要使用一次,它就会清除它的缓存,随后的调用将毫无用处。

于 2019-11-07T22:20:29.163 回答
4

我在运行下选择跳过所有断点选项或按 (CTRL+ALT+B) 作为快捷键。对于我的 STS,调试模式启动比以前更快

第 1 步:一旦我们应用 (CTRL+ALT+B) 断点被禁用,然后启动您的服务器,它将快速运行。

第2步:再次使用相同的快捷方式启用断点,然后你就可以调试了。

注意:除非应用 Step2 ,否则我们无法调试应用程序。

于 2020-04-16T20:22:37.407 回答
0

我相信这是正常的功能。Eclipse 使用资源,而调试模式将使用大量资源。

于 2019-11-07T19:18:20.070 回答
0

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

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

spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
于 2019-11-07T19:21:25.933 回答
0

我在运行下选择跳过所有断点选项或按 ( CTRL+ ALT+ B) 作为快捷键。对于我的 STS,调试模式启动比以前更快

第 1 步:一旦我们应用 ( CTRL++ ALT)B断点被禁用,然后启动你的服务器,它将快速运行。第2步:再次使用相同的快捷方式启用断点,然后你就可以调试了。

注意:除非应用 Step2 ,否则我们无法调试应用程序。

于 2020-12-11T13:45:28.547 回答