Jhipster 弹簧启动缓慢

Jhipster 弹簧启动缓慢,jhipster,Jhipster,当我使用“mvn spring boot:run”启动我的jhipster应用程序时,启动需要60秒。。。 我日志的第一部分是: [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building jhipster 0.0.1-SNAPSHOT [INFO] -------------------

当我使用“mvn spring boot:run”启动我的jhipster应用程序时,启动需要60秒。。。 我日志的第一部分是:

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building jhipster 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> spring-boot-maven-plugin:1.1.9.RELEASE:run (default-cli) @ jhipster >>>
[INFO]
[INFO] --- maven-enforcer-plugin:1.3.1:enforce (enforce-versions) @ jhipster ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ jhipster ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 4 resources
[INFO] Copying 22 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ jhipster ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ jhipster ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ jhipster ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] <<< spring-boot-maven-plugin:1.1.9.RELEASE:run (default-cli) @ jhipster <<<
[INFO]
[INFO] --- spring-boot-maven-plugin:1.1.9.RELEASE:run (default-cli) @ jhipster ---
[INFO] Attaching agents: []
Listening for transport dt_socket at address: 5005

我记得曾经使用过较旧版本的jhipster generator(0.17等),它在15-20秒内启动。 这是正常的还是我这边有问题?去哪里找

谢谢, 这太奇怪了。 实际上,它应该在5-15秒内启动,具体取决于您的机器和具体设置。 但是它不应该挂起30秒:您显示的行有点新,这是因为当您使用dev profile->可以在其上附加调试器时,我们以调试模式启动应用程序。
它似乎在等待您连接调试器:我自己从未见过它,所以您可能有一些特定的JVM选项,可以在启动时附加调试器,超时时间为30秒?

感谢您的反馈。我调查并在应用程序(Application.java)中添加了更多日志。 实际上,问题并不是来自调试模式,应用程序并不挂起在这里

第一个大的“暂停”来自于对liquibase包的扫描(addLiquibaseScanPackages();in Application.java):26秒! 我的第二次暂停仍然与Liquibase有关(日志“配置Liquibase”):20秒。在此期间,如果我将Liquibase日志级别设置为DEBUG,我会看到一个锁被设置,然后被释放,但它发生得非常快

我真的不明白。我使用的是h2内存数据库,JDK1.7.0_25和Maven 3.0.5,运行在MacBook Pro和SSD上。 这是我使用“mvn spring boot:run”运行时的完整日志

[INFO]正在扫描项目。。。
[信息]
[信息]------------------------------------------------------------------------
[信息]建筑jhipster 0.0.1-SNAPSHOT
[信息]------------------------------------------------------------------------
[信息]
[信息]>>>spring boot maven插件:1.1.9.版本:run(默认cli)@jhipster>>>
[信息]
[信息]---maven enforcer插件:1.3.1:enforce(强制版本)@jhipster---
[信息]
[信息]---maven资源插件:2.6:resources(默认资源)@jhipster---
[信息]使用“UTF-8”编码复制筛选的资源。
[信息]正在复制4个资源
[信息]正在复制22个资源
[信息]
[信息]---maven编译器插件:3.1:compile(默认编译)@jhipster---
[信息]无需编译-所有类都是最新的
[信息]
[信息]---maven资源插件:2.6:testResources(默认testResources)@jhipster---
[信息]使用“UTF-8”编码复制筛选的资源。
[信息]正在复制3个资源
[信息]
[信息]---maven编译器插件:3.1:testCompile(默认testCompile)@jhipster---
[信息]无需编译-所有类都是最新的
[信息]

[信息]我自己也经历了启动缓慢的时期,不知道原因是什么。我收到所有的控制台消息说各种事情已经开始,然后在最后一条消息说应用程序已经加载之前挂起

最终我发现我可以使用JavaVisualVM作为JDK的一部分来查看发生了什么。如果jdk在bin文件夹中安装了其jvisualvm.exe。然后,当我选择作为Application.java进行调试时,tomcat进程会弹出,您可以跟踪正在发生的事情

我在挂起的地方进行了几个线程转储,它似乎总是在生成swagger API文档的地方。更深入一点,这是在一个名为MetricsConfiguration的类中配置的,如果您使用名为“fast”的概要文件运行,该类将被排除

在eclipse中,我编辑了调试配置,以包含以下程序参数:

--spring.profiles.active=dev,fast
这将启动时间从230秒缩短到25秒

我进行了快速扫描,fast似乎禁用了各种功能。它主要看起来像是管理员菜单下的东西,在开发过程中可能不需要它。我个人更喜欢快速启动,而不是在开发过程中查看rest文档

大摇大摆的样子让我怀疑这到底是不是个好主意。它值这个价吗?然后我读了这篇文章,我正在考虑把它全部删除。这是一个好主意,但似乎为build+增加了33mb,这对我来说造成了启动时间非常缓慢


关于信息,我有大约16个实体。所以不小,但也不太大。

您可以像java-jar-Xmx1024m一样修改xmx。
因为当SpringBoot启动时,它会加载很多SpringBean。您可以添加堆内存以提高其性能

确保您没有在调试模式下运行服务器,并且设置了断点。这将我的一个应用程序的启动时间从3分钟缩短到22秒。

建议在禁用调试点的情况下启动应用程序,除非您只想在启动时调试30秒。

([INFO]org.myapp.Application-在230.105秒内启动应用程序(JVM运行230.971)这让我发疯。它挂在审计行之后,但当我删除它时,暂停就出现在之前的行上。按大约90秒的速度运行,按230s+的速度调试。我已经在这里尝试了所有的方法,并且我增加了eclipse可用的内存。没有想法了。我已经将我的发现写在了一个答案中。简短的答案基本上是虚张声势的!很快,你就知道了t损失了158秒。为启动添加更多内存是没有意义的,因为它会在生命周期的其余部分被浪费掉。
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building jhipster 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> spring-boot-maven-plugin:1.1.9.RELEASE:run (default-cli) @ jhipster >>>
[INFO]
[INFO] --- maven-enforcer-plugin:1.3.1:enforce (enforce-versions) @ jhipster ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ jhipster ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 4 resources
[INFO] Copying 22 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ jhipster ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ jhipster ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ jhipster ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] <<< spring-boot-maven-plugin:1.1.9.RELEASE:run (default-cli) @ jhipster <<<
[INFO]
[INFO] --- spring-boot-maven-plugin:1.1.9.RELEASE:run (default-cli) @ jhipster ---
[INFO] Attaching agents: []
Listening for transport dt_socket at address: 5005
Wed Nov 26 16:32:23 CET 2014 Added log : Application is about to start
Wed Nov 26 16:32:28 CET 2014Added log : Application started, now we set banner to false
Wed Nov 26 16:32:28 CET 2014Added log : About to add Default profile
Wed Nov 26 16:32:28 CET 2014Added log : Default Profile added. Now we scan liquibase packages
Wed Nov 26 16:32:28 CET 2014Added log : Liquibase pakages scanned. Now we run the app
2014-11-26 16:32:54,564 [INFO] com.mycompany.myapp.Application - Starting Application on MacBook-Pro.local with PID 25452 (/Users/othomas/Developpement/jhipster-1.9.0/target/classes started by othomas in /Users/othomas/Developpement/jhipster-1.9.0)
2014-11-26 16:32:54,567 [DEBUG] com.mycompany.myapp.Application - Running with Spring Boot v1.1.9.RELEASE, Spring v4.0.8.RELEASE
2014-11-26 16:32:57,429 [DEBUG] org.jboss.logging - Logging Provider: org.jboss.logging.Log4jLoggerProvider
2014-11-26 16:32:57,559 [DEBUG] com.mycompany.myapp.config.AsyncConfiguration - Creating Async Task Executor
2014-11-26 16:32:58,305 [DEBUG] com.mycompany.myapp.config.MetricsConfiguration - Registering JVM gauges
2014-11-26 16:32:58,379 [INFO] com.mycompany.myapp.config.MetricsConfiguration - Initializing Metrics JMX reporting
2014-11-26 16:32:58,445 [DEBUG] com.mycompany.myapp.config.DatabaseConfiguration - Configuring Datasource
2014-11-26 16:32:59,353 [DEBUG] com.mycompany.myapp.config.DatabaseConfiguration - Configuring Liquibase
2014-11-26 16:33:19,489 [DEBUG] com.mycompany.myapp.config.CacheConfiguration - Starting Ehcache
2014-11-26 16:33:19,491 [DEBUG] com.mycompany.myapp.config.CacheConfiguration - Registering Ehcache Metrics gauges
2014-11-26 16:33:23,419 [DEBUG] com.mycompany.myapp.config.MailConfiguration - Configuring mail server
2014-11-26 16:33:24,559 [INFO] com.mycompany.myapp.config.WebConfigurer - Web application configuration, using profiles: [dev]
2014-11-26 16:33:24,560 [DEBUG] com.mycompany.myapp.config.WebConfigurer - Initializing Metrics registries
2014-11-26 16:33:24,564 [DEBUG] com.mycompany.myapp.config.WebConfigurer - Registering Metrics Filter
2014-11-26 16:33:24,565 [DEBUG] com.mycompany.myapp.config.WebConfigurer - Registering Metrics Servlet
2014-11-26 16:33:24,567 [DEBUG] com.mycompany.myapp.config.WebConfigurer - Registering GZip Filter
2014-11-26 16:33:24,569 [DEBUG] com.mycompany.myapp.config.WebConfigurer - Initialize H2 console
2014-11-26 16:33:24,570 [INFO] com.mycompany.myapp.config.WebConfigurer - Web application fully configured
2014-11-26 16:33:29,753 [INFO] com.mycompany.myapp.Application - Running with Spring profile(s) : [dev]
2014-11-26 16:33:30,012 [INFO] com.mycompany.myapp.config.ThymeleafConfiguration - loading non-reloadable mail messages resources
2014-11-26 16:33:30,896 [DEBUG] com.mycompany.myapp.aop.logging.LoggingAspect - Enter: com.mycompany.myapp.repository.CustomAuditEventRepository.auditEventRepository() with argument[s] = []
2014-11-26 16:33:30,905 [DEBUG] com.mycompany.myapp.aop.logging.LoggingAspect - Exit: com.mycompany.myapp.repository.CustomAuditEventRepository.auditEventRepository() with result = com.mycompany.myapp.repository.CustomAuditEventRepository$1@1edce963
2014-11-26 16:33:37,229 [INFO] com.mycompany.myapp.Application - Started Application in 68.311 seconds (JVM running for 73.972)
Wed Nov 26 16:33:37 CET 2014Added log : App is running
--spring.profiles.active=dev,fast