首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Spring数据运行Spring Native应用程序需要大约2-3秒的启动时间

使用Spring数据运行Spring Native应用程序需要大约2-3秒的启动时间
EN

Stack Overflow用户
提问于 2021-11-09 16:06:28
回答 1查看 97关注 0票数 0

我已经用Spring Initializr创建了一个Spring Boot应用程序。我使用带有MySQL JDBC连接的Spring Data。我用gradle bootBuildImage创建了一个docker镜像,并用docker run --rm -p 8080:80 buchschrank:0.0.1-SNAPSHOT启动了这个docker镜像。但是启动需要2-3秒,而不是毫秒:

代码语言:javascript
复制
2021-11-09 16:03:32.238  INFO 1 --- [           main] o.s.nativex.NativeListener               : This application is bootstrapped with code generated with Spring AOT

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v2.5.6)

2021-11-09 16:03:32.277  INFO 1 --- [           main] o.s.boot.SpringApplication               : Starting application using Java 11.0.13 on 2b2e5a51334b with PID 1 (started by cnb in /workspace)
2021-11-09 16:03:32.277  INFO 1 --- [           main] o.s.boot.SpringApplication               : No active profile set, falling back to default profiles: default
2021-11-09 16:03:32.326  INFO 1 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2021-11-09 16:03:32.329  INFO 1 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 2 ms. Found 1 JPA repository interfaces.
2021-11-09 16:03:32.388  INFO 1 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 80 (http)
2021-11-09 16:03:32.389  INFO 1 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2021-11-09 16:03:32.389  INFO 1 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.54]
2021-11-09 16:03:32.395  INFO 1 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2021-11-09 16:03:32.395  INFO 1 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 116 ms
2021-11-09 16:03:32.412  INFO 1 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]
2021-11-09 16:03:32.414  INFO 1 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate ORM core version 5.4.32.Final
2021-11-09 16:03:32.415  INFO 1 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2021-11-09 16:03:32.417  INFO 1 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2021-11-09 16:03:33.840  INFO 1 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2021-11-09 16:03:33.842  INFO 1 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
2021-11-09 16:03:34.973  INFO 1 --- [           main] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2021-11-09 16:03:34.974  INFO 1 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2021-11-09 16:03:35.033  WARN 1 --- [           main] 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
2021-11-09 16:03:35.077  INFO 1 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 80 (http) with context path ''
2021-11-09 16:03:35.078  INFO 1 --- [           main] o.s.boot.SpringApplication               : Started application in 2.852 seconds (JVM running for 2.854)

我的示例应用程序的源代码:https://github.com/lesestunden/buchschrank-backend

你知道我的应用程序设置出了什么问题吗?非常感谢!

EN

回答 1

Stack Overflow用户

发布于 2021-11-15 11:36:15

原因是到数据库的初始连接速度很慢。在本地运行时,mysql数据库的启动时间约为200ms。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69901396

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档