当我使用“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
- &GT;然后它会挂起约30秒,然后继续:
[INFO] com.mycompany.myapp.Application - Starting Application on MacBook-Pro.local with PID 5130 (/Users/othomas/Developpement/jhipster-1.9.0/target/classes started by othomas in /Users/othomas/Developpement/jhipster-1.9.0)
[DEBUG] com.mycompany.myapp.Application - Running with Spring Boot v1.1.9.RELEASE, Spring v4.0.8.RELEASE
[DEBUG] org.jboss.logging - Logging Provider: org.jboss.logging.Log4jLoggerProvider
...
我记得曾使用过旧版本的jhipster生成器(0.17等),它在15-20秒内启动。 这是正常的还是我身边有问题?在哪里寻找?
谢谢, O操作。
答案 0 :(得分:6)
我自己一直在慢慢启动时间,并想知道原因是什么。我收到所有控制台消息,说明各种事情已经开始,然后它在最终消息之前挂起,说该应用程序已加载。
最终我发现我可以使用Java VisualVM作为JDK的一部分来查看正在发生的事情。如果你有jdk在bin文件夹中安装了jvisualvm.exe。然后,当我选择调试为Application.java时,会弹出tomcat进程,您可以跟踪正在进行的操作。
我挂了几个线程转储,它似乎总是在生成swagger API文档的地方。更多的挖掘,这是在名为MetricsConfiguration的类中配置的,如果您使用名为&#34; fast&#34;的配置文件运行,则会将其排除。
在eclipse中,我编辑了我的调试配置,以包含一个程序参数:
--spring.profiles.active=dev,fast
这将启动时间从230秒减少到25秒!
我进行了快速扫描,快速似乎禁用了各种各样的东西。它主要看起来像管理菜单下的东西,无论如何你在开发过程中可能都不需要。就个人而言,我更喜欢快速启动,以便能够在开发过程中看到其余的文档。
Swagger如此兴奋,让我想知道这毕竟是不是一个好主意。值得花费吗?然后我读了这个http://java.dzone.com/articles/swagger-great,我考虑完全删除它。这是一个不错的主意,但似乎为构建添加了33mb +对我来说导致启动时间非常慢。
有关信息,我有大约16个实体。所以不小但不过分大。
答案 1 :(得分:3)
确保您没有在调试模式下运行服务器并设置断点。这将我的一个应用程序的启动时间从3分钟减少到22秒。
答案 2 :(得分:0)
这很奇怪。 实际上,它应该在5-15秒内启动,具体取决于您的机器和特定设置。 但是它不应该挂起30秒:你显示的那条线有点新,因为我们在使用开发配置文件时以调试模式启动应用程序 - &gt;你可以在上面附加一个调试器。 它看起来好像在等你连接调试器:我自己从未见过它,所以也许你有一些特定的JVM选项可以在启动时连接一个调试器,超时为30秒? / p>
答案 3 :(得分:0)
感谢您的反馈。我调查并在应用程序中添加了更多日志(Application.java)。 实际上问题不是来自调试模式,应用程序不会挂起来。
第一个大&#34;暂停&#34;来自liquibase包的扫描(addLiquibaseScanPackages();在Application.java中):26秒! 我的第二次停顿仍然与Liquibase有关(log&#34;配置Liquibase&#34;):20秒。在此期间,如果我将Liquibase日志级别设置为DEBUG,我会看到锁定已设置然后释放但是很快就会发生。
我真的不明白。我正在使用h2内存数据库,jdk 1.7.0_25和Maven 3.0.5,在带有SSD的MacBook Pro上运行。 当我使用&#34; mvn spring-boot运行时,这是我的完整日志:运行&#34;。
[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
谢谢, 奥利弗
答案 4 :(得分:0)
建议在禁用调试点的情况下启动应用程序,除非您要在启动时进行调试
答案 5 :(得分:-1)
你可以像java -jar -Xmx1024m一样修改xmx。 因为当Spring启动时,它会加载很多spring bean。您可以添加堆内存以提高其性能。