2014-11-22 105 views
8

當我啓動使用我的jhipster應用「MVN春天啓動:運行」,它需要長達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 

- >然後它掛在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

這很奇怪。 事實上,它應該在5-15秒內啓動,具體取決於您的機器和具體設置。 但是它不應該掛起30秒:你顯示的這一行有點新,這是因爲我們在使用dev配置文件時以調試模式啓動應用程序 - >你可以在其上附加一個調試器。 它看起來像在等待你連接一個調試器:我從來沒有見過它,所以也許你有一些特定的JVM選項用於在啓動時連接一個調試器,超時時間爲30秒?

+0

只需30秒! :( [INFO] org.myapp.Application - 。在230.105秒(JVM運行230.971) – 2015-03-20 00:34:00

+0

這是推動我糊塗它掛的審計行之後,但是當我刪除它暫停了對前行啓動的應用程序運行大約90年代和調試230s +。我已經嘗試了一切在這裏http://stackoverflow.com/questions/11371393/tomcat-not-starting-through-eclipse-timeout加上我提高了日食可用的內存。想法 – 2015-03-23 00:34:31

+0

我已經在一個答案中寫下了我的研究結果,簡短的回答基本上是大開眼界! – 2015-03-25 18:36:14

0

感謝您的反饋。我調查並將更多的日誌放在應用程序中(Application.java)。 其實問題並不是來自調試模式,應用程序不會在這裏掛起。第一個大的「暫停」來自liquibase包(addLiquibaseScanPackages();在Application.java中)的掃描:26秒! 我的第二次暫停仍然與Liquibase(日誌「配置Liquibase」)相關:20秒。在此期間,如果我將Liquibase日誌級別設置爲DEBUG,則會看到設置了鎖定然後釋放,但發生速度非常快。

我真的不明白。我正在使用h2內存數據庫,jdk 1.7.0_25和Maven 3.0.5,在帶有SSD的MacBook Pro上運行。 這是我用「mvn spring-boot:run」運行時的完整日誌。

[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 = [email protected]e963 
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

我一直在痛苦慢速啓動時間自己,不知道原因是什麼。我得到了所有控制檯消息,說明各種事情已經開始,然後在最終消息說應用程序已加載之前掛起。

最終我發現我可以使用Java VisualVM作爲JDK的一部分來查看發生了什麼。如果您有jdk在bin文件夾中安裝了它的jvisualvm.exe。然後當我選擇調試Application.java時,tomcat進程彈出,你可以跟蹤發生了什麼。

我花了幾個線程轉儲掛起,它似乎總是生成swagger API文檔的位置。更多的挖掘,這是配置在一個名爲MetricsConfiguration的類中,如果使用名爲「fast」的配置文件運行,該類將被排除。

在Eclipse我編輯我的調試配置,包括方案論證:

--spring.profiles.active=dev,fast 

這減少了230秒,只有25的啓動時間!

我做了一個快速掃描和快速似乎禁用各種事情。它主要看起來像管理菜單下的東西,無論如何您在開發過程中可能都不需要這些東西。就個人而言,我更喜歡快速啓動,以便能夠在開發過程中查看其他文檔。

揚鞭是這樣一個豬讓我不知道,如果它是一個好主意。這是值得的成本?然後我讀了這個http://java.dzone.com/articles/swagger-great,我正在考慮完全刪除它。這是一個不錯的主意,但似乎增加了33MB的構建+對我來說,導致啓動時間非常緩慢。

對於信息我身邊有16個實體。所以不小,但不是太大。

0

你可以修改XMX像Java的罐子-Xmx1024m。 因爲當Spring啓動時,它會加載大量的spring bean。您可以添加堆內存來提高其性能。

0

確保你沒有運行在調試模式下的服務器,並有斷點集。這將我的一個應用程序的啓動時間從22秒縮短到3分鐘。

+0

大加速,你剛剛失去了158秒。 – 2017-11-10 08:01:05